require "Common/define"
require "Logic/Config"
require "Common/functions"

UIBattleMain = {};
HelperFunc.SetUIEnv(UIBattleMain)
local this = UIBattleMain;
this.openGoldenFinger = true;

function UIBattleMain.InitLocalData()
    this.gameObject = nil;
    this.transform = nil;
    this.LuaBehaviour = nil;

    this.leftSlider = nil;
    this.rightSlider = nil;
    this.leftSlider2 = nil;
    this.rightSlider2 = nil;
    this.leftHP = nil;
    this.rightHP = nil;

    this.effKaizhanSprine = nil
    this.effCutinLeft_cSprine = nil
    this.effCutinLeft_fSprine = nil
    this.effCutinLeft_bSprine = nil

    this.mainTime = nil;
    this.btnPause = nil;
    this.btnSpeed = nil;
    this.btnPlay = nil;
    this.btnSpeed2 = nil;
    this.btnSkip = nil;
    this.imgHeadList = {};
    this.objStarList = {};
    this.imgStarList = {};

    this.effKaizhan = nil;
    this.effCutinLeft_c = nil;
    this.effCutinLeft_f = nil;
    this.effCutinLeft_b = nil;

    this.bossSlider = nil;
    this.objEnergyList = nil;
    this.objMark = nil;
    this.bossEnergyList = {};
    this.bossName = nil;
    this.remainingTime = nil;
    this.heroHeadList = {};
    this.heroIconList = {};
    this.heroNameList = {};
    this.heroHPList = {};

    this.hasInit = false;
    this.battleRoundRoot = nil;
    this.roundCamera = nil;
    this.cameraMask = nil;
    this.fightTimer = nil;
    this.bossFighterId = 0;
    --this.curTimeScale = 1;
    this.BloodTime = 0.5;
    this.finishFunction = nil; --ս�������ص� ������ս�������Ӯ/�䣩
    this.skipCount = 0;
    this.battleInfo = {};
    this.myHelpMan = nil;
    this.mySkillIcon = nil;
    this.enemyHelpMan = nil;
    this.enemySkillIcon = nil;
    this.spineAniTimer = nil;
    this.typeController = nil;
    this.showAutoSkillCtrl = nil;
    this.trialScore = 0;
    this.allDamage = 0;
    this.curLevel = 1;

    this.myHeadLightSp = nil;
    this.enemyHeadLightSp = nil;
    this.mySkillLightSp = nil;
    this.enemySkillLightSp = nil;

    this.drawWrapperBs = {};
    this.cutInItems = nil;
    this.cutInEff_B = nil;
    this.cutInEff_F = nil;
    this.cutInEff_C = nil;
    this.cutInPos = 0;
    this.drawWrappers = {};
    this.showLiveHeroData = {};
    this.showLiveEnemyData = {};

    this.effYuanZhuBlue = nil;
    this.effYuanZhuRed = nil;
    this.aidSkillBlueSpine = nil;
    this.aidSkillRedSpine = nil;

    this.effYZSkillBlue = nil;
    this.effYZSkillRed = nil;
    this.effYZSkillBlueSpine = nil;
    this.effYZSkillRedSpine = nil;

    this.hideSkin = nil;
    this.helpSkillTran = nil;
    this.helpSkillSpine = nil;

    this.myHeroTitle = nil;
    this.myHeroTitle2 = nil;
    this.myHeroLiveList = nil;
    this.myHeroLiveList2 = nil;
    this.enemyHeroTitle = nil;
    this.enemyHeroTitle2 = nil;
    this.enemyHeroLiveList = nil;
    this.enemyHeroLiveList2 = nil;
    this.curMyShowTeamId = 0;--当前队伍id
    this.curEnemyShowTeamId = 0;

    this.guildMainHeroList = {};--工会boss主队头像列表
    this.guildHelpHeroList = {};--工会boss援助队头像列表
    this.mainFormationListCom = {};--工会boss战我方主队头像<partnerId,GComponent>
    this.helpFormationListCom = {};--工会boss战我方援助队头像<partnerId,GComponent>
    this.mainFormationListRendererData = {}--工会boss战我方主队英雄
    this.helpFormationListRendererData = {}--工会boss战我方援助队英雄
    this.bossBloodBar = nil;
    this.bossHpText = nil;

    this.killShowCom = nil;---击杀表现组件
    this.killShowCtrl = nil;---击杀表现控制器
    this.killerHead = nil;--击杀者
    this.targetHead = nil;--被击杀者头像
    this.killShowNumCtrl = nil;--击杀次数控制器
    this.killShowAni = nil;--击杀动画

    this.supSkillGroup = nil;--援助技能表现
    this.supSkillBack = nil;--援助技能表现后层
    this.supSkillFront = nil;--援助技能表现前层
    this.supHelpMan = nil;--替补立绘位置
    this.supHelpManSpine = nil;--替补立绘spine
    this.supSkillBackSpine = nil;--援助技能表现后层特效
    this.supSkillFrontSpine = nil;--援助技能表现前层特效
    this.supSkillHeroModel = nil;--援助技能支援位英雄位置
    this.supSkillIcon = nil;--援助技能图标
    this.utimerLiHuiFade = nil;--立绘渐入渐出计时器
    this.supSkillTempTimeSkill = 1;--支援技能表现timeScale
    --组合技
    this.combinationCom = nil;--组合技详情页面
    this.showCombCtrl = nil;--组合技列表控制器
    this.showCombPageCtrl = nil;--组合技显示控制器
    this.combinationSkillList = nil;--组合技我方列表
    this.enemyCombinationSkillList = nil;--组合技敌方列表
    --击杀顺序
    this.killList = nil;--击杀列表组件
    this.killDataList = {};--击杀信息
    this.killDataShowList = {};--击杀信息
    this.killListRefreshUTimer = nil;--刷新击杀顺序列表的utimer
    --心之试炼
    this.curBloodBarNum = 0;
    this.allSoloBossBloodBar = nil;--总血条com
    this.soloBossBloodBar = nil;--血条com
    this.soloBossBloodBarCtrl = nil;--血条颜色控制器
    this.soloBossBloodBarText = nil;--血条数值
    this.soloBossDamageText = nil--总输出值
    this.soloBossBloodBarEndCtrl = nil;
    this.eventCtrl = nil
    this.autoCtrl = nil
    this.btnAuto = nil
    this.btnEvent = nil
    this.eventTime = nil
    this.eventTimeId = nil
    this.stateCtrl = nil
    this.levelName = nil
    this.levelCtrl = nil
    this.isShow = true
    this.performCtrl = nil
    --释放技能图标
    this.skillBtnList = {}
    this.skillBtnListByModelId = {}--根据modelid存按钮
    this.showAutoSkillCtrl = {};
end

this.InitLocalData()

local CVType = {
    BEGAN = "f_OpenningAudio",
    SP_SKILL = "f_SPAudio",
    VICTORY = "f_VictoryAudio",
    FAILURE = "f_FailureAudio",
}

function UIBattleMain.Init(finishAct)
    finishFunction = finishAct;
    local name, packageName = getUIName(PanelNames.UIBattleMain);
    panelMgr:ShowUI(name, packageName, this.onCreate, Config.useLocalUI);
end

function UIBattleMain.onCreate(obj)
    FightManager.IsBattleFight = true
    isEnter = true;
    --常规战斗界面背景音乐
    -- AudioManager.SetSwitch("battle_steps", "fight")
    --AudioManager.PlaySound(8,obj)
    AudioManager.Play(523)

    gameObject = obj;
    this.openGoldenFinger = Config.RemoteConfig.GoldenFinger == 1
    this.isShowResultUI = false
    if not hasInit then
        hasInit = true;
        battleRoundRoot = panelMgr.BattleRound;
        battleRoundRoot.gameObject:SetActive(true);
        delayDisableCamera = false
        roundCamera = battleRoundRoot.transform:Find("CameraRound"):GetComponent("Camera");
        cameraMask = battleRoundRoot.transform:Find("MaskPlane");
        if cameraMask ~= nil then
            cameraMask.gameObject:SetActive(false);
        end
        bossHead = obj:GetChild("BossHead");
        bossBloodProgressBar = obj:GetChild("BossBloodBar");
        bossDamageText = bossBloodProgressBar:GetChild("damage");
        bossBuff = obj:GetChild("BossBuff");
        bossNameText = obj:GetChild("BossName");
        typeController = obj:GetController("type");

        myHelpMan = obj:GetChild("myHelpMan")
        mySkillIcon = obj:GetChild("SkillLeft")
        enemyHelpMan = obj:GetChild("enemyHelpMan")
        enemySkillIcon = obj:GetChild("SkillRight")
        leftSlider = obj:GetChild("Slider");

        rightSlider = obj:GetChild("redSlider");
        leftSlider2 = leftSlider:GetChild("Slider2");
        rightSlider2 = rightSlider:GetChild("redSlider2");
        this.leftSliderController = leftSlider:GetController("type");
        this.rightSliderController = rightSlider:GetController("type");
        this.leftSlider2Controller = leftSlider2:GetController("type");
        this.rightSlider2Controller = rightSlider2:GetController("type");

        mainTime = obj:GetChild("n55");
        leftHP = leftSlider:GetChild("LeftHP");
        rightHP = rightSlider:GetChild("RightHP");

        btnPause = obj:GetChild("pause");
        btnPlay = obj:GetChild("play");
        --btnSpeed = obj:GetChild("speed");
        btnSpeed2 = obj:GetChild("speed2");
        btnSpeed3 = obj:GetChild("speed3");
        btnSkip = obj:GetChild("skip");
        --btnSkip.visible = false;
        hideSkin = obj:GetChild("skip1");
        --[[屏蔽前端战斗 autoSkillCtrl = obj:GetController("autoSkill");--自动技能表现控制器
         --[[屏蔽前端战斗btnAutoSkill = obj:GetChild("autoSkill"); --自动技能按钮]]
        myHeadLightSp = obj:GetChild("myHeadLight");
        enemyHeadLightSp = obj:GetChild("enemyHeadLight");
        mySkillLightSp = obj:GetChild("mySkillLight");
        enemySkillLightSp = obj:GetChild("enemySkillLight");

        myHeroShow = obj:GetChild("myHero");
        myHeroShow:GetController("type").selectedIndex = 0
        myHeroTitle = myHeroShow:GetChild("textCurrent");
        myHeroTitle2 = myHeroShow:GetChild("textAnother");

        myHeroLiveList = myHeroShow:GetChild("list");
        myHeroLiveList2 = myHeroShow:GetChild("list2");
        enemyHeroShow = obj:GetChild("enemy")
        enemyHeroShow:GetController("type").selectedIndex = 1
        enemyHeroTitle = enemyHeroShow:GetChild("textCurrent");
        enemyHeroTitle2 = enemyHeroShow:GetChild("textAnother");
        enemyHeroLiveList = enemyHeroShow:GetChild("list");
        enemyHeroLiveList2 = enemyHeroShow:GetChild("list2");

        helpSkillTran = obj:GetTransition("Effect_SupSkill");
        supSkillTran = obj:GetTransition("Effect_SupSkill_UI");
        --helpSkillSpine = obj:GetChild("Effect_SupSkill");
        Text_SupSkillName = obj:GetChild("Text_SupSkillName");
        this.performCtrl = obj:GetController("performCtrl")

        this.eventCtrl = obj:GetController("RandomEvent")
        this.autoCtrl = obj:GetController("autoFight")
        this.btnAuto = obj:GetChild("auto")
        this.btnEvent = obj:GetChild("btnRandomEvent")
        this.eventTime = this.btnEvent:GetChild("time")
        this.stateCtrl = obj:GetController("state")
        this.levelName = obj:GetChild("CurrentLevel")
        this.levelCtrl = obj:GetController("showLevel")

        this.killShowCom = obj:GetChild("Com_KillMessage");
        this.killShowCtrl = obj:GetController("broadcast");
        this.killShowNumCtrl = killShowCom:GetController("kill");
        this.killerHead = killShowCom:GetChild("Btn_Head01");
        this.targetHead = killShowCom:GetChild("Btn_Head02");
        this.killShowAni = killShowCom:GetTransition("Effect_Kill");
        this.guildMainHeroList = obj:GetChild("mainFormationList");
        this.guildHelpHeroList = obj:GetChild("helpFormationList");
        this.bossBloodBar = obj:GetChild("BossBloodBaGuildr");
        this.bossHpText = this.bossBloodBar:GetChild("damage");
        this.boxNum = obj:GetChild("n174");

        this.btn_bullet_chat = obj:GetChild("bulletChat") --弹幕聊天按钮
        this.bullet_mode_controller = this.btn_bullet_chat:GetController("bulletmode")
        this.bullet_chat_controller = obj:GetController("SpBattleLog") --this.btn_bullet_chat

        this.btnPetShow = obj:GetChild("showInfo");--查看职业加成

        this.killList = obj:GetChild("List_Message");--击杀顺序列表
        this.killList.itemRenderer = this.killListItem;
        --[[屏蔽前端战斗 this.showAutoSkillCtrl = obj:GetController("showAutoSkill");]]
         if Config.OpenCommentAndBullet then
             if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.BulletChat) then
                 this.bullet_chat_controller:SetSelectedIndex(0)
                 if chatHandler.IsOpenBulletFunction() then
                     this.bullet_mode_controller:SetSelectedIndex(0)
                 else
                     this.bullet_mode_controller:SetSelectedIndex(1)
                 end
             else
                 this.bullet_chat_controller:SetSelectedIndex(1)
                 this.bullet_mode_controller:SetSelectedIndex(1)
             end
         else
             this.bullet_chat_controller:SetSelectedIndex(1)
         end

         this.Com_BattleMainHeadLeft = obj:GetChild("Com_BattleMainHeadLeft");
         this.Com_Btn_HeadLeft = this.Com_BattleMainHeadLeft:GetChild("Btn_Head");
         this.Com_Text_PlayerNameLeft = this.Com_BattleMainHeadLeft:GetChild("Text_PlayerName");
         this.Com_TypeLeft = this.Com_BattleMainHeadLeft:GetController("Type");
         this.Com_BattleMainHeadRight = obj:GetChild("Com_BattleMainHeadRight");
         this.Com_Btn_HeadRight = this.Com_BattleMainHeadRight:GetChild("Btn_Head");
         this.Com_Text_PlayerNameRight = this.Com_BattleMainHeadRight:GetChild("Text_PlayerName");
         this.Com_TypeRight = this.Com_BattleMainHeadRight:GetController("Type");
         this.cutInItems = {};
         local imgIcon = obj:GetChild("cutIn");
         this.cutInItems = imgIcon;
         imgIcon.visible = false;
         local effCutinLeft_c = this.cutInItems:GetChild("ui_battle_cutinleft_c");
         local effCutinLeft_f = this.cutInItems:GetChild("ui_battle_cutinleft_f");
         local effCutinLeft_b = this.cutInItems:GetChild("ui_battle_cutinleft_b");
         this.cutInEff_C = effCutinLeft_c;

         resMgr:LoadModelPrefab("Prefabs/UISpine/ui_battle_cutinleft_f", function(go)
             local drawWrapper = drawWrappers["Prefabs/UISpine/ui_battle_cutinleft_f"];
             if drawWrapper == nil then
                 drawWrapper = GoWrapper.New()
             end

             local effCutinLeft_fSprine = this.cutInEff_F;
             if effCutinLeft_fSprine ~= nil then
                 destroyImmediate(effCutinLeft_fSprine)
                 effCutinLeft_fSprine = nil
             end
             effCutinLeft_fSprine = newObject(go);

             effCutinLeft_fSprine:AddComponent(TCanvas);

             drawWrapper:SetWrapTarget(effCutinLeft_fSprine, false)
             Util.Lua_SetLocalPositionXYZ(effCutinLeft_fSprine.transform, 0, 0, 0)
             if effCutinLeft_f then
                 effCutinLeft_f:SetNativeObject(drawWrapper)
                 this.cutInEff_F = effCutinLeft_fSprine;
             else
                 if effCutinLeft_fSprine then
                     destroyImmediate(effCutinLeft_fSprine)
                     effCutinLeft_fSprine = nil;
                 end
             end
         end)

         if effCutinLeft_bSprine ~= nil then
             destroyImmediate(effCutinLeft_bSprine)
             effCutinLeft_bSprine = nil
         end

         resMgr:LoadModelPrefab("Prefabs/UISpine/ui_battle_cutinleft_b", function(go)
             local drawWrapper = drawWrappers["Prefabs/UISpine/ui_battle_cutinleft_b"];
             if drawWrapper == nil then
                 drawWrapper = GoWrapper.New()
             end
             local effCutinLeft_bSprine = this.cutInEff_B;

             effCutinLeft_bSprine = newObject(go);

             effCutinLeft_bSprine:AddComponent(TCanvas);

             drawWrapper:SetWrapTarget(effCutinLeft_bSprine, false)
             Util.Lua_SetLocalPositionXYZ(effCutinLeft_bSprine.transform, 0, 0, 0)
             if effCutinLeft_b then
                 effCutinLeft_b:SetNativeObject(drawWrapper)
                 this.addEvent();
                 this.cutInEff_B = effCutinLeft_bSprine;
             else
                 if effCutinLeft_bSprine then
                     destroyImmediate(effCutinLeft_bSprine);
                     effCutinLeft_bSprine = nil
                 end
             end
         end)
         if FightManager.fightType == EnumConst.FightTypeConst.RankBattle or FightManager.fightType == EnumConst.FightTypeConst.FriendAttack or FightManager.fightType == EnumConst.FightTypeConst.GuildBattlePlus
                 or FightManager.fightType == EnumConst.FightTypeConst.SoloChaosTest then
             this.leftSliderController.selectedIndex = FightManager.teamRest[1] - 1;
             this.rightSliderController.selectedIndex = FightManager.teamRest[1] - 1;
             this.leftSlider2Controller.selectedIndex = FightManager.teamRest[1] - 1;
             this.rightSlider2Controller.selectedIndex = FightManager.teamRest[1] - 1;
         else
             this.leftSliderController.selectedIndex = 0;
             this.rightSliderController.selectedIndex = 0;
             this.leftSlider2Controller.selectedIndex = 0;
             this.rightSlider2Controller.selectedIndex = 0;
         end
         rightSlider.value = 100;
         leftSlider.value = 100;
         rightHP.text = "100%";
         leftHP.text = "100%";
         trialScore = 0;

         -- 战斗时长
         if FightManager.fightType == EnumConst.FightTypeConst.TRIAL then
             local battleRecord = BattlePlaybackManager.getBattleRecord() or {}
             local maxBattleSeconds = battleRecord.maxBattleSeconds or 0
             local battleTime = maxBattleSeconds == 0 and logicMgr.MapManager.getMaxTime() or maxBattleSeconds
             mainTime.text = timeToTimeFormat_MS(battleTime);
         else
             mainTime.text = timeToTimeFormat_MS(logicMgr.MapManager.getMaxTime());
         end

         this.effKaizhan = obj:GetChild("ui_kaizhan");

         resMgr:LoadModelPrefab("Prefabs/UISpine/ui_kaizhan", function(go)
             if HelperFunc.IsNull(this.effKaizhan) then
                 return ;
             end
             local drawWrapper = drawWrappers["ui_kaizhan"]
             if not drawWrapper then
                 drawWrapper = GoWrapper.New();
                 this.drawWrappers["ui_kaizhan"] = drawWrapper
             end
             if this.effKaizhanSprine ~= nil then
                 destroyImmediate(this.effKaizhanSprine);
                 this.effKaizhanSprine = nil
             end
             this.effKaizhanSprine = newObject(go);
             this.effKaizhanSprine:AddComponent(TCanvas);
             drawWrapper:SetWrapTarget(this.effKaizhanSprine, false)
             Util.Lua_SetLocalPositionXYZ(this.effKaizhanSprine.transform, 0, 0, 0)
             if this.effKaizhan then
                 this.effKaizhan:SetNativeObject(drawWrapper)
             else
                 if this.effKaizhanSprine ~= nil then
                     destroyImmediate(this.effKaizhanSprine);
                     this.effKaizhanSprine = nil
                 end
             end

             effKaizhan.visible = false;
             -- Util.WaitForSeconds(function()
             --     if Util.IsNull(effKaizhan) then
             --         return
             --     end
             --     effKaizhan.visible = true;
             --     AudioManager.Play(AudioManager.Play_UI_Start_Fight)
             --     if BattlePlaybackManager.GetFightType() == EnumConst.FightTypeConst.INSTANCE then
             --         local skeGraphic = this.effKaizhanSprine:GetComponent("SkeletonGraphic");
             --         if skeGraphic ~= nil and skeGraphic.Skeleton and skeGraphic.AnimationState then
             --             skeGraphic.AnimationState:SetAnimation(0, "idle" .. (BattlePlaybackManager.GetFightIndex() + 1), false);
             --             skeGraphic:Update(0);
             --         end
             --     end
             -- end, 2.1);

             ubattletimer.delayCall(function()
                 if Util.IsNull(effKaizhan) then
                     return
                 end
                 effKaizhan.visible = true
                 AudioManager.Play(AudioManager.Play_UI_Start_Fight)
                 if BattlePlaybackManager.GetFightType() == EnumConst.FightTypeConst.INSTANCE
                         or BattlePlaybackManager.GetFightType() == EnumConst.FightTypeConst.GuildBattlePlus
                         or BattlePlaybackManager.GetFightType() == EnumConst.FightTypeConst.SoloChaosTest
                 then
                     local skeGraphic = this.effKaizhanSprine:GetComponent("SkeletonGraphic")
                     if skeGraphic ~= nil and skeGraphic.Skeleton and skeGraphic.AnimationState then
                         skeGraphic.AnimationState:SetAnimation(0, "idle" .. (BattlePlaybackManager.GetFightIndex() + 1), false)
                         skeGraphic:Update(0)
                     end
                 end
             end, 1500)
             if FightManager.fightType == EnumConst.FightTypeConst.PerformBattle then
                 ubattletimer.delayCall(function()
                     logicMgr.StoryMgr.ShowStoryById(5001011, EnumConst.StoryShowType.review, logicMgr.StoryMgr.callback)
                     Time.timeScale = 0;
                 end, 1450)
             end
         end)

         this.effYuanZhuBlue = obj:GetChild("headEff_blue");
         this.effYZSkillBlue = obj:GetChild("skillEff_blue");

         resMgr:LoadModelPrefab("Prefabs/UISpine/ui_yuanzhu_lan", function(go)

             local drawWrapper = drawWrappers["Prefabs/UISpine/ui_yuanzhu_lan"]
             if not drawWrapper then
                 drawWrapper = GoWrapper.New();
                 this.drawWrappers["Prefabs/UISpine/ui_yuanzhu_lan"] = drawWrapper
             end
             if aidSkillBlueSpine ~= nil then
                 destroyImmediate(aidSkillBlueSpine);
                 aidSkillBlueSpine = nil
             end
             aidSkillBlueSpine = newObject(go);

             aidSkillBlueSpine:AddComponent(TCanvas);

             drawWrapper:SetWrapTarget(aidSkillBlueSpine, false)
             Util.Lua_SetLocalPositionXYZ(aidSkillBlueSpine.transform, 0, 0, 0)

             if this.effYuanZhuBlue then
                 this.effYuanZhuBlue:SetNativeObject(drawWrapper);
             else
                 if aidSkillBlueSpine ~= nil then
                     destroyImmediate(aidSkillBlueSpine);
                     aidSkillBlueSpine = nil
                 end
             end
         end)

         if this.effYZSkillBlueSpine ~= nil then
             destroyImmediate(this.effYZSkillBlueSpine);
             this.effYZSkillBlueSpine = nil
         end
         resMgr:LoadModelPrefab("Prefabs/UISpine/ui_yuanzhu_lan", function(go)
             local drawWrapper_1 = drawWrappers["Prefabs/UISpine/ui_yuanzhu_lan_1"]
             if not drawWrapper_1 then
                 drawWrapper_1 = GoWrapper.New();
                 this.drawWrappers["Prefabs/UISpine/ui_yuanzhu_lan_1"] = drawWrapper_1
             end
             if this.effYZSkillBlueSpine then
                 destroyImmediate(this.effYZSkillBlueSpine)
                 this.effYZSkillBlueSpine = nil;
             end
             this.effYZSkillBlueSpine = newObject(go);

             this.effYZSkillBlueSpine:AddComponent(TCanvas);

             drawWrapper_1:SetWrapTarget(this.effYZSkillBlueSpine, false)
             Util.Lua_SetLocalPositionXYZ(this.effYZSkillBlueSpine.transform, 0, 0, 0)
             if this.effYZSkillBlue then
                 this.effYZSkillBlue:SetNativeObject(drawWrapper_1);
             else
                 if this.effYZSkillBlueSpine then
                     destroyImmediate(this.effYZSkillBlueSpine)
                     this.effYZSkillBlueSpine = nil;
                 end
             end
         end)

         this.effYuanZhuRed = obj:GetChild("headEff_red");
         this.effYZSkillRed = obj:GetChild("skillEff_red");

         resMgr:LoadModelPrefab("Prefabs/UISpine/ui_yuanzhu_h", function(go)
             local drawWrapper = drawWrappers["Prefabs/UISpine/ui_yuanzhu_h"]
             if not drawWrapper then
                 drawWrapper = GoWrapper.New();
                 this.drawWrappers["Prefabs/UISpine/ui_yuanzhu_h"] = drawWrapper
             end
             if aidSkillRedSpine ~= nil then
                 destroyImmediate(aidSkillRedSpine);
                 aidSkillRedSpine = nil
             end

             aidSkillRedSpine = newObject(go);

             aidSkillRedSpine:AddComponent(TCanvas);

             drawWrapper:SetWrapTarget(aidSkillRedSpine, false)
             Util.Lua_SetLocalPositionXYZ(aidSkillRedSpine.transform, 0, 0, 0)
             if this.effYuanZhuRed then
                 this.effYuanZhuRed:SetNativeObject(drawWrapper);
             else
                 if aidSkillRedSpine ~= nil then
                     destroyImmediate(aidSkillRedSpine);
                     aidSkillRedSpine = nil
                 end
             end
         end)

         resMgr:LoadModelPrefab("Prefabs/UISpine/ui_yuanzhu_h", function(go)
             local drawWrapper_1 = drawWrappers["Prefabs/UISpine/ui_yuanzhu_h_1"]
             if not drawWrapper_1 then
                 drawWrapper_1 = GoWrapper.New();
                 this.drawWrappers["Prefabs/UISpine/ui_yuanzhu_h_1"] = drawWrapper_1
             end

             if this.effYZSkillRedSpine ~= nil then
                 destroyImmediate(this.effYZSkillRedSpine);
                 this.effYZSkillRedSpine = nil
             end

             this.effYZSkillRedSpine = newObject(go);

             this.effYZSkillRedSpine:AddComponent(TCanvas);

             drawWrapper_1:SetWrapTarget(this.effYZSkillRedSpine, false)
             Util.Lua_SetLocalPositionXYZ(this.effYZSkillRedSpine.transform, 0, 0, 0)
             this.effYZSkillRed:SetNativeObject(drawWrapper_1);
         end)

         logicMgr.GuideMgr.BattleStart()
     end
     closeUI(PanelResNames.UIHeadMenu)
     myHeadLightSp.visible = false;
     enemyHeadLightSp.visible = false;
     mySkillLightSp.visible = false;
     enemySkillLightSp.visible = false;
     --skillEditor中第一次加载，这是两个Head，第二次加载就变成GComponent对象，具体原因未知，可能是资源管理的问题，第一次关闭时把依赖的battleCommon包卸载了，所以后边没加载出来
     local head = enemyHelpMan:GetChild("icon");
     if head then
         enemyHelpMan:GetChild("icon").grayed = false;
         myHelpMan:GetChild("icon").grayed = false;
     end

     delayDisableCamera = false
     if battleRoundRoot ~= nil then
         battleRoundRoot.gameObject:SetActive(true);
         if roundCamera ~= nil then
             FightManager.setCamera(roundCamera);
         end
     end

     this.supSkillGroup = obj:GetChild("Group_SupSkill");
     --this.supSkillGroup.visible = false;
     this.supSkillBack = obj:GetChild("eff_zyj_back");
     this.supSkillFront = obj:GetChild("eff_zyj_front");
     this.supSkillIcon = obj:GetChild("Com_SupSkill");
     this.supHelpMan = obj:GetChild("Img_HeroModel");
     this.supSkillType = obj:GetController("Type");
     local defineDrawing = obj:GetChild("Graph_HeroModel");
     defineDrawing.visible = false;
     local fighterId = 6;
     for i, v in pairs(FightManager.helpManFightId) do
         if v.teamIndex == 1 then
             fighterId = v.fighterId;
         end
     end
     if fighterId ~= 0 then
         local fighter = FightManager.getEntityByFighterId(fighterId);
         if fighter ~= nil then
             local modelId = fighter.partnerModelId;
             if modelId == "610" then
                 modelId = "61";
             end
             local path = HeroManager.GetHeroDrawingPath(modelId, nil, logicMgr.SkinManager.getHeroSkinId(modelId));
             if path then
                 if FightManager.battleInfo.mySupSkill ~= 0 then
                     this.supSkillType.selectedIndex = 1;
                 else
                     this.supSkillType.selectedIndex = 0;
                 end
                 resMgr:LoadModelPrefab(path, function(go)
                     local drawWrapper = drawWrappers[path]
                     if not drawWrapper then
                         drawWrapper = GoWrapper.New();
                         this.drawWrappers[path] = drawWrapper;
                     end
                     if supHelpManSpine ~= nil then
                         destroyImmediate(supHelpManSpine);
                         supHelpManSpine = nil
                     end
                     supHelpManSpine = newObject(go);
                     supHelpManSpine:AddComponent(TCanvas);
                     drawWrapper:SetWrapTarget(supHelpManSpine, false)
                     local skinId = fighter.skinId;
                     if fighter.skinId == nil then
                         skinId = logicMgr.SkinManager.getHeroSkinId(modelId);
                     end
                     local resize, location = HeroManager.GetHeroSupShowLocationResizeBySkinId(skinId)
                     local tempPos = Vector3.New(location[1], location[2], 0);
                     Util.Lua_SetLocalPositionXYZ(supHelpManSpine.transform, tempPos.x, tempPos.y, tempPos.z)
                     local tempScale = Vector3.New(resize[1], resize[2], 1);
                     Util.Lua_SetLocalScaleXYZ(supHelpManSpine.transform, tempScale.x, tempScale.y, tempScale.z)
                     --Util.Lua_SetLocalScaleXYZ(supHelpManSpine.transform, 1.5, 1.5, 1.5)
                     if this.supHelpMan then
                         this.supHelpMan:SetNativeObject(drawWrapper);
                     else
                         if supHelpManSpine then
                             destroyImmediate(supHelpManSpine);
                             supHelpManSpine = nil;
                         end
                     end
                 end)
             end

         end
     else
         this.supSkillType.selectedIndex = 2;
     end

     resMgr:LoadModelPrefab("UIEff/UI_zyj_02", function(go)
         local drawWrapper = drawWrappers["UIEff/UI_zyj_02"]
         if not drawWrapper then
             drawWrapper = GoWrapper.New();
             this.drawWrappers["UIEff/UI_zyj_02"] = drawWrapper;
         end
         if supSkillFrontSpine ~= nil then
             destroyImmediate(supSkillFrontSpine);
             supSkillFrontSpine = nil
         end
         supSkillFrontSpine = newObject(go);
         supSkillFrontSpine:AddComponent(TCanvas);
         drawWrapper:SetWrapTarget(supSkillFrontSpine, false)
         Util.Lua_SetLocalPositionXYZ(supSkillFrontSpine.transform, 0, 0, 0)
         if this.supSkillFront then
             this.supSkillFront:SetNativeObject(drawWrapper);
         else
             if supSkillFrontSpine ~= nil then
                 destroyImmediate(supSkillFrontSpine);
                 supSkillFrontSpine = nil
             end
         end
     end)

     resMgr:LoadModelPrefab("UIEff/UI_zyj_suduxian_01", function(go)
         local drawWrapper = drawWrappers["UIEff/UI_zyj_suduxian_01"]
         if not drawWrapper then
             drawWrapper = GoWrapper.New();
             this.drawWrappers["UI_zyj_suduxian_01"] = drawWrapper;
         end
         if supSkillBackSpine ~= nil then
             destroyImmediate(supSkillBackSpine);
             supSkillBackSpine = nil
         end
         supSkillBackSpine = newObject(go);
         supSkillBackSpine:AddComponent(TCanvas);
         drawWrapper:SetWrapTarget(supSkillBackSpine, false)
         Util.Lua_SetLocalPositionXYZ(supSkillBackSpine.transform, 0, 0, 0)
         if this.supSkillBack then
             this.supSkillBack:SetNativeObject(drawWrapper);
         else
             if supSkillBackSpine ~= nil then
                 destroyImmediate(supSkillBackSpine);
                 supSkillBackSpine = nil
             end
         end
     end)


     --[[
         local monsters = FightManager.fight.teams[1].fighters;
         local isboss = 0;
         for i=1,#monsters do
             local modelId = monsters[i].partnerModelId;
             local fighterId = monsters[i].fighterId;
             local monsterConfig = G.dataTable["t_monster"][tostring(partnerModelId)];
             if monsterConfig ~= nil then
                 isboss = monsterConfig.f_Boss;
                 if isboss == 1 then
                     bossFighterId = fighterId;
                     bossName.text = monsterConfig.f_MonsterName;
                     break;
                 end
             end
         end
         if isboss == 1 then
             bossSlider.gameObject:SetActive(true);
             obEnergyList:SetActive(true);
             objMark:SetActive(true);
             bossName.gameObject:SetActive(true);
         else
             bossSlider.gameObject:SetActive(false);
             obEnergyList:SetActive(false);
             objMark:SetActive(false);
             bossName.gameObject:SetActive(false);
         end

         local teamFighters = FightManager.fight.teams[0].fighters;
         for i=1,#teamFighters do
             local fighterId = teamFighters[i].fighterId;
             local maxHP = teamFighters[i].totalAttribute[EnumConst.FighterAttributeEnum.HP];
             local hp = teamFighters[i].hp;
             bossSlider.value = hp/maxHP;
         end

     ]]
    this.ClearTimer()
    btnPause.visible = true;
    btnPlay.visible = false;
    logicMgr.FuncOpenManager.addStatusCtr(PanelNames.UIBattleMain, Config.FuncOpenType.autoAttack, btnAuto.name, btnAuto);
    logicMgr.FuncOpenManager.addStatusCtr(PanelNames.UIBattleMain, Config.FuncOpenType.BattleSpeed, btnSpeed2.name, btnSpeed2);
    logicMgr.FuncOpenManager.addStatusCtr(PanelNames.UIBattleMain, Config.FuncOpenType.BattleSpeed_5, btnSpeed3.name, btnSpeed3);
    logicMgr.FuncOpenManager.addStatusCtr(PanelNames.UIBattleMain, Config.FuncOpenType.BattleTeamPet, this.btnPetShow.name, this.btnPetShow);
    logicMgr.FuncOpenManager.addStatusCtr(PanelNames.UIBattleMain, this.getSkipFuncOpenType(), btnSkip.name, btnSkip);
    if logicMgr.DungeonRandomEventManager.getEventState() and FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
        eventCtrl.selectedIndex = 1
        if eventTimeId then
            utimer.remove(eventTimeId)
            eventTimeId = nil
        end
        local timeCount = logicMgr.DungeonRandomEventManager.getDungeonRandomEventDataEndTime() - HelperFunc.GetServerTime()
        eventTime.text = TimeFormatToHHMMSS(timeCount)
        eventTimeId = utimer.timeCall(function()
            timeCount = timeCount - 1
            if timeCount > 0 then
                eventTime.text = TimeFormatToHHMMSS(timeCount)
            else
                utimer.remove(eventTimeId)
                eventTimeId = nil
                eventCtrl.selectedIndex = 0
            end
        end, 1000, -1)
    else
        eventCtrl.selectedIndex = 0
    end
    if FightManager.isAuto then
        autoCtrl.selectedIndex = 1
    else
        autoCtrl.selectedIndex = 0
    end
    this.performCtrl.selectedIndex = 0
    --[[屏蔽前端战斗 this.showAutoSkillCtrl.selectedIndex = 1;]]

     if FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
         local mapId = logicMgr.MapManager.GetAutoMapId();
         local current = G.dataTable["t_stage"][tostring(mapId)];
         levelName.text = current.f_ChapterId .. "-" .. current.f_StageNum;
         this.stateCtrl.selectedIndex = 0
         this.levelCtrl.selectedIndex = 1
     elseif FightManager.fightType == EnumConst.FightTypeConst.RealMan then
         local cfgId = tonumber(logicMgr.RealManWarManager.GetRealManPlayerInfo().step);
         local abyssCfg = dataTable.getDataTableByStringId("t_abyss", cfgId);
         if abyssCfg ~= nil then
             levelName.text = string.format(getLanguage("SoloBattle_Level"), getLanguage("SoloBattle_difficulty0" .. abyssCfg.f_Rank), abyssCfg.f_RankLevel);
         else
             levelName.text = "";
         end
         this.stateCtrl.selectedIndex = 0;
         this.levelCtrl.selectedIndex = 1;
     elseif FightManager.fightType == EnumConst.FightTypeConst.TOWER then
         local towerType = logicMgr.TowerManager.getClimbType();
         local curTowerInfo = logicMgr.TowerManager.returnTowerInfo(towerType);
         local curTowerlevel = 1;
         if curTowerInfo ~= nil then
             curTowerlevel = tonumber(curTowerInfo["layerId"]);
             if curTowerlevel > 1 then
                 curTowerlevel = curTowerlevel - 1;
             end
         end
         levelName.text = string.format("第%d层", curTowerlevel);

         this.stateCtrl.selectedIndex = 0;
         this.levelCtrl.selectedIndex = 1;
     elseif FightManager.fightType == EnumConst.FightTypeConst.StoryBattle then
         local mapId, groupId = logicMgr.MapManager.GetStoryHardAutoMapId();
         local current = logicMgr.StoryHardManager.getDungeonTableDataById(mapId)
         levelName.text = string.format("%s-%s-%s", current.f_ChapterId, current.f_StageNum, groupId);
         this.stateCtrl.selectedIndex = 0
         this.levelCtrl.selectedIndex = 1
     elseif FightManager.fightType == EnumConst.FightTypeConst.PerformBattle then
         this.performCtrl.selectedIndex = 1
     else
         this.stateCtrl.selectedIndex = 1
         this.levelCtrl.selectedIndex = 0
     end
     if FightManager.isRePlay then
         eventCtrl.selectedIndex = 0
         this.stateCtrl.selectedIndex = 1
         this.levelCtrl.selectedIndex = 0
         --当前战斗是回放 隐藏或一些按钮
         this.btnPetShow.visible = false;
     elseif FightManager.isRePlay and table.getn(FightManager.paramTeamBonus) > 0 and FuncOpenManager.isOpen(Config.FuncOpenType.BattleTeamPet) then
         this.btnPetShow.visible = true;
     end
     if not FightManager.isRePlay and FightManager.fightType == EnumConst.FightTypeConst.DUNGEON and not this.checkDungeonSkip() then
         btnSkip.grayed = true;
     end
     local speed = GetPlayerPrefs("UIBattleMainSpeed" .. logicMgr.HeroManager.GetRoleInfo("playerId"));
     local speedNum = tonumber(speed);
     FightManager.curTimeScale = FightManager.timeScaleLv_1;
    --[[屏蔽前端战斗 local automaticSkillsStr = GetPlayerPrefs("UIBattleMainAutomaticSkills" .. logicMgr.HeroManager.GetRoleInfo("playerId"));
     FightManager.isAutoSkill = tonumber(automaticSkillsStr) == 1;
     --手动技能不能5倍速
     this.automaticSkills(nil, true)
     local autoSkill = GetPlayerPrefs("autoSkill" .. logicMgr.HeroManager.GetRoleInfo("playerId"));
     if autoSkill then
         FightManager.isAutoSkill = tonumber(autoSkill) == 1;
     else
         SetPlayerPrefs("autoSkill" .. logicMgr.HeroManager.GetRoleInfo("playerId"), "0")
         FightManager.isAutoSkill = false;
     end
 ]]
     AudioManager.SetRTPCValue("game_speed", (100 / FightManager.curTimeScale))
     if speedNum == 1 then
         this.onClickBtnSpeed2();
     elseif speedNum == 2 then
         if FightManager.fightType ~= EnumConst.FightTypeConst.RankBattle then
             this.onClickBtnSpeed3();
         else
             this.onClickBtnSpeed2();
         end
     else
         this.onClickBtnSpeed1();
     end
     if FightManager.fightType == EnumConst.FightTypeConst.SoloChaosTest then
         --btnSpeed3.visible = false;
         btnSkip.visible = false;
     end
     if FightManager.fightType == EnumConst.FightTypeConst.StoryBattle then
         btnSpeed3.visible = false;
     end
     battleInfo = FightManager.battleInfo;
     if battleInfo.mySupSkill or battleInfo.enemySupSkill or battleInfo.myHelpPartnerModelId or battleInfo.enemyHelpPartnerModelId then
         this.refreshIcons(battleInfo);
     end
     this.combinationCom = obj:GetChild("HeroComb");
     this.showCombCtrl = obj:GetController("Combination");
     this.showCombPageCtrl = obj:GetController("showComb");
     this.combinationSkillList = obj:GetChild("CombinationList");
     this.combinationSkillListBgCtrl = obj:GetController("Combination")
     this.enemyCombinationSkillList = obj:GetChild("CombinationList_Enemy");
     this.enemyCombinationSkillListBgCtrl = obj:GetController("CombinationEnemy");
     if FightManager.fightType ~= EnumConst.FightTypeConst.GuildBoss then
         local formation = {};
         local formationEnemy = {};
         for i, v in pairs(FightManager.mainFormationFightId) do
             for idx, param in pairs(v) do
                 if i == 1 then
                     table.insert(formation, param.modelId);
                 else
                     table.insert(formationEnemy, param.modelId);
                 end
             end
         end
         if FightManager.battleInfo.myHelpPartnerModelId then
             local myHelpManId = tostring(FightManager.battleInfo.myHelpPartnerModelId);
             table.insert(formation, myHelpManId);
         end
         if FightManager.battleInfo.enemyHelpPartnerModelId and tonumber(FightManager.battleInfo.enemyHelpPartnerModelId) ~= 0 then
             table.insert(formationEnemy, tostring(FightManager.battleInfo.enemyHelpPartnerModelId));

         end
         local combinationSkillList = HeroManager.getCombinationSkillList(formation);
         local combinationSkillEnemyList = HeroManager.getCombinationSkillList(formationEnemy);

         if table.getn(combinationSkillList) > 0 then
             this.combinationSkillListBgCtrl.selectedIndex = 1;
         else
             this.combinationSkillListBgCtrl.selectedIndex = 0;
         end

         local isPvE = FightManager.checkIsFightTypePVE();
         if not isPvE and table.getn(combinationSkillEnemyList) > 0 then
             this.enemyCombinationSkillList.visible = true;
             this.enemyCombinationSkillListBgCtrl.selectedIndex = 1;
             this.enemyCombinationSkillList.itemRenderer = function(idx, obj)
                 local data = combinationSkillEnemyList[idx + 1]
                 this.rendererCombinationSkill(data, obj, 2);
             end
             this.enemyCombinationSkillList.numItems = table.getn(combinationSkillEnemyList);
         else
             if FightManager.fightType ~= EnumConst.FightTypeConst.TRIAL then
                 this.enemyCombinationSkillList.visible = false;
                 this.enemyCombinationSkillListBgCtrl.selectedIndex = 0;
             end
         end

         this.combinationSkillList.itemRenderer = function(idx, obj)
             local data = combinationSkillList[idx + 1]
             this.rendererCombinationSkill(data, obj, 1);
         end
         this.combinationSkillList.numItems = table.getn(combinationSkillList);
     else
         this.combinationSkillListBgCtrl.selectedIndex = 0;
         this.enemyCombinationSkillListBgCtrl.selectedIndex = 0;
     end

     this.mainFormationListRendererData = {};
     this.helpFormationRendererListData = {};
     for i = 1, #FightManager.initFighterList do
         local fighter = FightManager.initFighterList[i];
         if fighter.teamIndex == 1 then
             if fighter.isHero and fighter.modelId ~= 0 then
                 local isMainFormation = true;
                 for k, v in pairs(FightManager.helpManFightId) do
                     if v.fighterId == fighter.fighterId then
                         isMainFormation = false;
                     end
                 end
                 if isMainFormation and fighter.partnerModelId ~= "610" then
                     table.insert(this.mainFormationListRendererData, fighter);
                 end
             end
         end
     end

     for k, v in pairs(logicMgr.GuildManager.helpManInfos) do
         v.dead = false;
         if v.partnerModelId ~= "610" then
             table.insert(this.helpFormationRendererListData, v);
         end
     end

     if FightManager.fightType == EnumConst.FightTypeConst.TRIAL and battleInfo.bossId and tonumber(battleInfo.bossId) > 0 then
         this.SetChaoTestBoWenEffActive()
         typeController.selectedIndex = 1;
         local bossConfig = logicMgr.HeroManager.GetHeroConfigbyModelId(battleInfo.bossId);
         curLevel = 1;
         bossHead:GetChild("head"):GetChild("HeadIcon").url = "ui://ICONAtlas/" .. bossConfig.f_HeroIcon;
         bossHead:GetChild("n16").url = "ui://ICONAtlas/" .. EnumConst.HeroTypeIcon[bossConfig.f_HeroType];
         bossBloodProgressBar.value = 100;
         bossBuff:GetChild("level").text = 1;
         --bossBuff:GetChild("icon"):GetChild("icon").url = "ui://SkillAtlas/" .. battleInfo.skillId;
         bossNameText.text = getLanguage(bossConfig.f_HeroName);
     elseif FightManager.fightType == EnumConst.FightTypeConst.INSTANCE then
         --BattlePlaybackManager.GetFightIndex() == 3 and
         typeController.selectedIndex = 2;

         ListenEvent(Config.EventType.Fight_Dead_id, this.heroDeadShow);
         this.refreshHeroShow()
     elseif FightManager.fightType == EnumConst.FightTypeConst.StoryBattle then
         typeController.selectedIndex = 6
     elseif FightManager.fightType == EnumConst.FightTypeConst.RankBattle then
         typeController.selectedIndex = 3;
         local _battleRecord = BattlePlaybackManager.getBattleRecord()
         local myInfo = _battleRecord["attacker"];
         local enemyInfo = _battleRecord["defender"];
         this.Com_TypeLeft.selectedIndex = 0;
         this.Com_TypeRight.selectedIndex = 1;
         if tostring(_battleRecord["defender"]["playerId"]) == tostring(logicMgr.HeroManager.GetRoleId()) then
             this.Com_TypeLeft.selectedIndex = 1;
             this.Com_TypeRight.selectedIndex = 0;
         end
         this.Com_Btn_HeadLeft:GetChild("head"):GetChild("HeadIcon").url = logicMgr.SkinManager.GetHeroIconBySkinId(myInfo.pic)--EnumConst.AtlasPath.ICONAtlas .. dataTable.getRow("t_hero", myInfo.pic)["f_HeroIcon"];
         this.Com_Btn_HeadLeft:GetChild("frame").url = EnumConst.AtlasPath.ICONAtlas .. myInfo.picFrame;
         this.Com_Text_PlayerNameLeft.text = myInfo.playerName;
         this.Com_Btn_HeadRight:GetChild("head"):GetChild("HeadIcon").url = logicMgr.SkinManager.GetHeroIconBySkinId(enemyInfo.pic)--EnumConst.AtlasPath.ICONAtlas .. dataTable.getRow("t_hero", enemyInfo.pic)["f_HeroIcon"];
         this.Com_Btn_HeadRight:GetChild("frame").url = EnumConst.AtlasPath.ICONAtlas .. enemyInfo.picFrame;
         this.Com_Text_PlayerNameRight.text = enemyInfo.playerName;
     elseif FightManager.fightType == EnumConst.FightTypeConst.ARENA then

         local formation_type = logicMgr.BattlePlaybackManager.GetFormationType()
         if formation_type and formation_type == EnumConst.FormationType.TeamCrossArenaAtk then
             typeController:SetSelectedIndex(5)
             local my_victory_or_defeat1 = gameObject:GetChild("MyVictoryOrDefeat1")
             local ctrl_my_state = {}
             ctrl_my_state[1] = my_victory_or_defeat1:GetController("state")
             local my_victory_or_defeat2 = gameObject:GetChild("MyVictoryOrDefeat2")
             ctrl_my_state[2] = my_victory_or_defeat2:GetController("state")
             local my_victory_or_defeat3 = gameObject:GetChild("MyVictoryOrDefeat3")
             ctrl_my_state[3] = my_victory_or_defeat3:GetController("state")

             local ctrl_enemy_state = {}
             local enemy_victory_or_defeat1 = gameObject:GetChild("EnemyMyVictoryOrDefeat1")
             ctrl_enemy_state[1] = enemy_victory_or_defeat1:GetController("state")
             local enemy_victory_or_defeat2 = gameObject:GetChild("EnemyMyVictoryOrDefeat2")
             ctrl_enemy_state[2] = enemy_victory_or_defeat2:GetController("state")
             local enemy_victory_or_defeat3 = gameObject:GetChild("EnemyMyVictoryOrDefeat3")
             ctrl_enemy_state[3] = enemy_victory_or_defeat3:GetController("state")
             local cur_battle_index = BattlePlaybackManager.GetFightIndex()
             local battle_data = FightManager.cross_team_battle_data
             for i = 1, 3 do
                 if i < cur_battle_index then
                     local win_state = battle_data[i] and battle_data[i].win or 0
                     if win_state == 1 then
                         ctrl_my_state[i]:SetSelectedIndex(1)
                         ctrl_enemy_state[i]:SetSelectedIndex(2)
                     else
                         ctrl_my_state[i]:SetSelectedIndex(2)
                         ctrl_enemy_state[i]:SetSelectedIndex(1)
                     end
                 else
                     ctrl_my_state[i]:SetSelectedIndex(0)
                 end
             end
             ctrl_my_state = nil
         else
             typeController:SetSelectedIndex(0)
         end
     elseif FightManager.fightType == EnumConst.FightTypeConst.GuildBoss then
         typeController.selectedIndex = 4;
         bossBuff.y = gameObject:GetChild("n172").y;
         gameObject:GetChild("n122").y = bossBuff.y + bossBuff.height;
         bossBuff:GetChild("level").text = 1;
         this.boxNum.text = 1;

         this.guildMainHeroList.itemRenderer = this.rendererGuildBossMainHero;
         this.guildHelpHeroList.itemRenderer = this.rendererGuildBossHelpHero;
         this.guildMainHeroList.numItems = #this.mainFormationListRendererData;
         this.guildHelpHeroList.numItems = #this.helpFormationRendererListData;
         this.bossBloodBar.value = 0;
         this.boxNum.text = 0;
         this.bossHpText.text = "0";
         ListenEvent(Config.EventType.Fight_Dead_id, this.refreshGuildBossHeroShow);
         this.refreshGuildBossHeroShow({ id = "0" });
     elseif FightManager.fightType == EnumConst.FightTypeConst.SoloChaosTest then
         -----------------心之试炼--------
         this.hpBar = obj:GetChild("Com_BossHp");
         this.allSoloBossBloodBar = this.hpBar:GetChild("Bar_TotalHp");--总血条com
         this.soloBossBloodBar = this.hpBar:GetChild("Bar_Hp");--血条com
         this.soloBossBloodBarCtrl = this.soloBossBloodBar:GetController("turn");--血条颜色控制器
         this.soloBossBloodBarText = this.hpBar:GetChild("Text_Hp");--血条数值
         this.soloBossDamageText = this.hpBar:GetChild("Text_Damage");--总输出值
         this.soloBossNameText = obj:GetChild("BossName");--boss名字
         this.soloBossBloodBarEndCtrl = this.hpBar:GetController("Endless");--是否是最终boss
         local bossData = G.dataTable["t_hero"][tostring(SoloChaosTestManager.getBossId())]
         local bossHead = obj:GetChild("BossHead");--boss头像
         local soleBossName = obj:GetChild("BossName");
         soleBossName.text = getLanguage(bossData.f_HeroName);
         this.bossHeadIcon = bossHead:GetChild("head"):GetChild("HeadIcon");
         this.bossType = bossHead:GetChild("n16");
         this.bossHeadIcon.url = "ui://ICONAtlas/" .. logicMgr.HeroManager.GetHeroIconByModelId(bossData.f_HeroID);
         this.bossType.url = "ui://ICONAtlas/" .. EnumConst.HeroTypeIcon[bossData.f_HeroType];
         typeController.selectedIndex = 7;
         --[[屏蔽前端战斗this.showAutoSkillCtrl.selectedIndex = 0;]]
         this.soloBossBloodBarEndCtrl.selectedIndex = 1;
         this.soloBossEffectTexts = {}--跳字伤害表现队列
         if logicMgr.SoloChaosTestManager.getNowBossId() == logicMgr.SoloChaosTestManager.getEndLessBossId() then
             this.hpBar.visible = false;
             this.soloBossBloodBarEndCtrl.selectedIndex = 0;
         else
             this.bloodSpeed = 200;--血条流动速度
             this.curBloodBarValue = 100;--当前逻辑血条值
             this.curShowBloodBarValue = 100;--当前显示的血条值
             this.curBloodBarNum = -1;--当前逻辑血条数量
             this.curShowBloodBarNum = -1;--当前显示血条数量
             this.soloBossUTimer = ubattletimer.frameCall(function()
                 this.changeBlood()
             end, -1)
             this.changeBlood = function()
                 local dt = Time.deltaTime;
                 --当前血条缓动
                 if this.curShowBloodBarNum <= 0 then
                     return ;
                 end
                 local bloodBarNumDt = math.abs(this.curBloodBarNum - this.curShowBloodBarNum);--逻辑血条和显示血条差值
                 if (this.curShowBloodBarValue < this.curBloodBarValue and this.curBloodBarNum == this.curShowBloodBarNum) or this.curBloodBarNum > this.curShowBloodBarNum then
                     --当前血条加血
                     --this.curShowBloodBarValue = this.curShowBloodBarValue + dt * this.bloodSpeed * (1 + (bloodBarNumDt - 1 * 0.75));
                     --if this.curShowBloodBarValue >= this.curBloodBarValue and this.curBloodBarNum == this.curShowBloodBarNum then
                     --    --到达逻辑血条位置
                     --    this.curShowBloodBarValue = this.curBloodBarValue;
                     --end
                     --if this.curShowBloodBarValue >= 100 then
                     this.changeBloodNum()
                     --    this.curShowBloodBarValue = 0;
                     --end
                     this.soloBossBloodBar.value = this.curBloodBarValue;
                 elseif (this.curShowBloodBarValue > this.curBloodBarValue and this.curBloodBarNum == this.curShowBloodBarNum) or this.curBloodBarNum < this.curShowBloodBarNum then
                     --当前血条扣血
                     this.curShowBloodBarValue = this.curShowBloodBarValue - dt * this.bloodSpeed * (1 + (bloodBarNumDt - 1 * 0.75));
                     if this.curShowBloodBarValue <= this.curBloodBarValue and this.curBloodBarNum == this.curShowBloodBarNum then
                         --到达逻辑血条位置
                         this.curShowBloodBarValue = this.curBloodBarValue;
                     end
                     if this.curShowBloodBarValue <= 0 then
                         this.changeBloodNum()
                         if this.curShowBloodBarNum > 0 then
                             this.curShowBloodBarValue = 100;
                         end
                     end
                     this.soloBossBloodBar.value = this.curShowBloodBarValue;
                 else
                     --无血量变化
                     return
                 end
             end
             this.updateBossHP(0)

             this.changeBloodNum = function()
                 --跨血条
                 if this.curBloodBarNum > this.curShowBloodBarNum then
                     --跨血条加血
                     if this.curShowBloodBarValue >= 100 then
                         this.curShowBloodBarNum = this.curShowBloodBarNum + 1;
                         this.changeBloodColor()
                     end
                 elseif this.curBloodBarNum < this.curShowBloodBarNum then
                     if this.curShowBloodBarValue <= 100 then
                         this.curShowBloodBarNum = this.curShowBloodBarNum - 1;
                         this.changeBloodColor()
                     end
                 end
                 this.soloBossBloodBarText.text = "X " .. this.curShowBloodBarNum;--血条数值

             end
             this.changeBloodColor = function()
                 if this.curShowBloodBarNum <= 1 then
                     if this.soloBossBloodBarCtrl.selectedIndex == 0 then
                         this.soloBossBloodBarCtrl.selectedIndex = 2;
                     else
                         this.soloBossBloodBarCtrl.selectedIndex = 3;
                     end
                 else
                     --血条颜色不同
                     if this.soloBossBloodBarCtrl.selectedIndex == 0 then
                         this.soloBossBloodBarCtrl.selectedIndex = 1;
                     else
                         this.soloBossBloodBarCtrl.selectedIndex = 0;
                     end
                 end
             end
         end


     else
         typeController.selectedIndex = 0;
     end

     if HeroManager.GetRoleId() == "" then
         --[[屏蔽前端战斗    this.showAutoSkillCtrl.selectedIndex = 0]]
         end

         if FightManager.fightType == EnumConst.FightTypeConst.RankBattle and (not FightManager.isRePlay) then
             btnSpeed3.visible = false
         end

    --[[屏蔽前端战斗         for i = 1, 6 do
             local btn = obj:GetChild("heroSkillBtn" .. i);
             btn.visible = false;
             table.insert(this.skillBtnList, btn)
         end
         if FightSelect.isShowSaveReport then
             for i = 1, #FightManager.initFighterList do
                 local fighter = FightManager.initFighterList[i];
                 if fighter.teamIndex == 1 then
                     local heroConfig = logicMgr.HeroManager.GetHeroConfigbyModelId(fighter.partnerModelId);
                     local item = this.skillBtnList[fighter.fighterId];
                     if item then

                         if not heroConfig then
                             item.visible = false;
                         else
                             item.visible = true;
                             item:GetChild("head"):GetChild("HeadIcon").url = "ui://ICONAtlas/" .. heroConfig.f_HeroIcon;
                             item:GetChild("n16").url = "ui://ICONAtlas/" .. EnumConst.HeroTypeIcon[heroConfig.f_HeroType];
                             item:GetChild("energy").value = fighter.energy / 1000;
                             if logicMgr.FightSelect.isShowSaveReport then
                                 this.skillBtnList[fighter.fighterId].onClick:Add(function()
                                     if FightManager.isAutoSkill then
                                         return ;
                                     end
                                     local entity = FightManager.fighterMap[fighter.fighterId]
                                     if entity.fighterClass:checkOverHitTarget() then
                                         local target = entity.fighterClass:getOverHitTarget();
                                         if target then
                                             ClientFight.SkillClientManager.useSkill(ClientFight.FightClientManager.fight, entity.fighterClass, target, entity.fighterClass:getOverHit(), true)
                                         end
                                     end
                                 end)
                             end
                             this.skillBtnListByModelId[fighter.partnerModelId] = this.skillBtnList[fighter.fighterId];
                         end
                     end
                 end
             end
         end]]
         isEnter = false;
     end

     function UIBattleMain.killShow(param)
         local fighter = param.fighter;
         local killer = param.killer;
         local killData = {}
         killData.killer = killer;
         killData.fighter = fighter;
         killData.showAni = false;
         killData.time = 2000;
         killData.isStop = false;
         table.insert(this.killDataList, killData);
         --if this.killListRefreshUTimer == nil then
         --    this.killListRefreshUTimer = ubattletimer.timeCall(function()
         --        this.killListRefreshFunc(true)
         --    end
         --    , 100, -1);
         --end
         local killNum = killer.killNum;
         --this.killListRefreshFunc()
         if killNum > 30 then
             return
         end
         this.killShowCom.visible = true;
         this.killShowAni:Stop();
         this.killShowAni:Play(function()
             this.killShowCom.visible = false;
         end)
         this.killShowNumCtrl.selectedIndex = killNum - 1;
         local killerHeadCtrl = this.killerHead:GetController("c3");--外框颜色
         killerHeadCtrl.selectedIndex = killer.teamIndex == 1 and 1 or 2;
         local supSkillId = killer.teamIndex == 1 and battleInfo.mySupSkill or battleInfo.enemySupSkill;
         local skillData = G.dataTable["t_skillshow"][tostring(supSkillId)];
         local killerHeadIcon = "ui://ICONAtlas/icon_hero_995";
         if killer.icon == nil and skillData ~= nil then
             --支援技击杀
             killerHeadIcon = "ui://SkillAtlas/" .. skillData.f_SkillIcon;
         elseif killer.icon then
             killerHeadIcon = "ui://ICONAtlas/" .. killer.icon;
         end
         this.killerHead:GetChild("head"):GetChild("HeadIcon").url = killerHeadIcon;

         local headIcon = "ui://ICONAtlas/" .. fighter.icon;
         if fighter.icon == nil then
             --支援技击杀
             headIcon = "ui://SkillAtlas/" .. skillData.f_SkillIcon;
         end
         local targetHeadCtrl = this.targetHead:GetController("c3");--外框颜色
         targetHeadCtrl.selectedIndex = fighter.teamIndex == 1 and 1 or 2;
         this.targetHead:GetChild("head"):GetChild("HeadIcon").url = headIcon;

         this.killShowCtrl.selectedIndex = 1;


     end

     function UIBattleMain.refreshGuildBossHeroShow(id)
         for k, v in pairs(this.mainFormationListRendererData) do
             if tonumber(v.partnerModelId) == tonumber(id.id) then
                 v.dead = true;
                 break
             end
         end
         for k, v in pairs(this.helpFormationRendererListData) do
             if tonumber(v.partnerModelId) == tonumber(id.id) then
                 v.dead = true;
                 break ;
             end
         end
         this.guildMainHeroList.itemRenderer = this.rendererGuildBossMainHero;
         this.guildHelpHeroList.itemRenderer = this.rendererGuildBossHelpHero;
         this.guildMainHeroList.numItems = #this.mainFormationListRendererData;
         this.guildHelpHeroList.numItems = #this.helpFormationRendererListData;
     end


     --type 1刷新我方队伍 2 刷新敌方队伍 nil刷新双方队伍
     function UIBattleMain.refreshHeroShow(type)
         local _battleRecord = BattlePlaybackManager.getBattleRecord()
         if _battleRecord then
             local FightData = BattlePlaybackManager.GetMultiDataAll();

             if myHeroTitle and (type == 1 or type == nil) then
                 showLiveHeroData = MythicDungeonsProManager.GetBattleFormations(1)
                 curMyShowTeamId = FightData.teamId;
                 myHeroTitle.text = getLanguage("MythicDungeons_tips" .. (curMyShowTeamId == 1 and "12" or "13"))
                 myHeroTitle2.text = getLanguage("MythicDungeons_tips" .. (curMyShowTeamId == 2 and "12" or "13"))

                 myHeroLiveList.itemRenderer = this.rendererLiveHero;
                 myHeroLiveList2.itemRenderer = this.rendererLiveHero2;

                 myHeroLiveList.height = myHeroLiveList:AddItemFromPool().height * table.getn(showLiveHeroData[curMyShowTeamId]) + myHeroLiveList.lineGap * table.getn(showLiveHeroData[curMyShowTeamId]);
                 myHeroLiveList2.height = myHeroLiveList2:AddItemFromPool().height * table.getn(showLiveHeroData[3 - curMyShowTeamId]) + myHeroLiveList2.lineGap * table.getn(showLiveHeroData[3 - curMyShowTeamId]);

                 myHeroLiveList.numItems = table.getn(showLiveHeroData[curMyShowTeamId]);
                 myHeroLiveList2.numItems = table.getn(showLiveHeroData[3 - curMyShowTeamId]);

             end

             if enemyHeroTitle and (type == 2 or type == nil) then
                 showLiveEnemyData = MythicDungeonsProManager.GetBattleFormations(2)
                 curEnemyShowTeamId = FightData.enemyTeamId;
                 enemyHeroTitle.text = getLanguage("MythicDungeons_tips" .. (curEnemyShowTeamId == 1 and "12" or "13"))
                 enemyHeroTitle2.text = getLanguage("MythicDungeons_tips" .. (curEnemyShowTeamId == 2 and "12" or "13"))

                 enemyHeroLiveList.itemRenderer = this.rendererLiveEnemyHero;
                 enemyHeroLiveList2.itemRenderer = this.rendererLiveEnemyHero2;

                 enemyHeroLiveList.height = enemyHeroLiveList:AddItemFromPool().height * table.getn(showLiveEnemyData[curEnemyShowTeamId]) + enemyHeroLiveList.lineGap * table.getn(showLiveEnemyData[curEnemyShowTeamId]);
                 enemyHeroLiveList2.height = enemyHeroLiveList2:AddItemFromPool().height * table.getn(showLiveEnemyData[3 - curEnemyShowTeamId]) + enemyHeroLiveList2.lineGap * table.getn(showLiveEnemyData[3 - curEnemyShowTeamId]);

                 enemyHeroLiveList.numItems = table.getn(showLiveEnemyData[curEnemyShowTeamId]);
                 enemyHeroLiveList2.numItems = table.getn(showLiveEnemyData[3 - curEnemyShowTeamId]);
             end
         end
     end

     function UIBattleMain.rendererHero(idx, obj, info)
         local charactor = CtrlManager.GetCtrl(PanelNames.HeadRectItem);
         --local ctrl = itemobj:GetTransition("Effect_List")
         --ctrl:Play()
         local hero = info.heroIds[idx];
         if charactor ~= nil then
             --初始英雄信息
             local heroData = {};
             logicMgr.HeroManager.copyHeroConfigbyModelId(hero, heroData);

             if heroData then
                 charactor.initData(obj, heroData, nil, nil, nil, nil, nil, nil, true);
                 obj.touchable = false;
             end
         end
     end
     --显示组合技详情
     function UIBattleMain.onShowComb(heroData)
         this.showCombPageCtrl.selectedIndex = 1;
         local heroList = this.combinationCom:GetChild("hero");
         heroList.itemRenderer = function(idx, obj)
             this.rendererHero(idx + 1, obj, heroData);
         end
         local cfg = HeroManager.getCombinationInfo()[tostring(heroData.skillId)];
         heroList.numItems = table.getn(heroData.heroIds);
         local desText = this.combinationCom:GetChild("Describe");
         desText.text = getLanguage(heroData.decs);

         local skillNameText = this.combinationCom:GetChild("title");
         skillNameText.text = getLanguage(cfg.f_CombinationName);

         local iconImg = this.combinationCom:GetChild("icon");
         iconImg.url = "ui://SkillAtlas/" .. cfg.f_CombinationIcon;

     end


     --显示组合技能
     function UIBattleMain.rendererCombinationSkill(data, obj, teamIdx)
         local cfg = HeroManager.getCombinationInfo();
         local nameText = obj:GetChild("title");
         local iconImg = obj:GetChild("icon");
         local typeCtrl = obj:GetController("type");
         iconImg.url = "ui://SkillAtlas/" .. cfg[tostring(data.skillId)].f_CombinationIcon;
         nameText.text = getLanguage(cfg[tostring(data.skillId)].f_CombinationName);
         typeCtrl.selectedIndex = teamIdx - 1;
         obj.onClick:Clear();
         obj.onClick:Add(function()
             UIBattleMain.onShowComb(data);
         end)

     end

     function UIBattleMain.rendererGuildBossMainHero(idx, obj)
         local data = this.mainFormationListRendererData[idx + 1];
         local stateController = obj:GetController("state")
         if data.dead then
             stateController.selectedIndex = 2;
         else
             stateController.selectedIndex = 0;
         end
         obj:GetChild("head"):GetChild("icon").url = "ui://ICONAtlas/" .. data.icon;

         --go.progress = obj:GetChild("head"):GetChild("maskProgress");
         --go.hpPercentage = obj:GetChild("HpNum");
         --UIBattleMain.rendererGuildBossHeroItem(data, go)
         this.mainFormationListCom[data.partnerModelId] = go;
     end

     function UIBattleMain.rendererGuildBossHelpHero(idx, obj)
         local data = this.helpFormationRendererListData[idx + 1];
         local stateController = obj:GetController("state")
         if data.dead then
             stateController.selectedIndex = 2;
         else
             stateController.selectedIndex = 1;
         end
         obj:GetChild("head"):GetChild("icon").url = "ui://ICONAtlas/" .. data.icon;

         --UIBattleMain.rendererGuildBossHeroItem(data, go)
     end

     function UIBattleMain.rendererLiveHero(idx, obj)
         local data = showLiveHeroData[curMyShowTeamId][idx + 1];
         UIBattleMain.rendererItemByObjAndData(data, obj)
     end

     function UIBattleMain.rendererLiveHero2(idx, obj)
         local data = showLiveHeroData[3 - curMyShowTeamId][idx + 1];
         UIBattleMain.rendererItemByObjAndData(data, obj)
     end

     function UIBattleMain.rendererLiveEnemyHero(idx, obj)
         local data = showLiveEnemyData[curEnemyShowTeamId][idx + 1];
         UIBattleMain.rendererItemByObjAndData(data, obj)
     end

     function UIBattleMain.rendererLiveEnemyHero2(idx, obj)
         local data = showLiveEnemyData[3 - curEnemyShowTeamId][idx + 1];
         UIBattleMain.rendererItemByObjAndData(data, obj)
     end

     function UIBattleMain.rendererItemByObjAndData(data, obj)
         local itemValue = logicMgr.HeroManager.getHeroDatabyModelId(data.data.partnerModelId);
         obj:GetController("state").selectedIndex = data.state;
         itemValue.star = data.data.star;
         itemValue.level = data.data.level;

         local charactor = CtrlManager.GetCtrl(PanelNames.HeadRectItem);
         if charactor ~= nil then
             --初始英雄信息
             itemValue["state"] = 0;
             charactor.initData(obj:GetChild("hero"), itemValue, nil);
         end
     end

     function UIBattleMain.heroDeadShow(data)
         if FightManager.fightType == EnumConst.FightTypeConst.INSTANCE then
             --更新死亡数据
             local teamType = data.teamId == 1 and curMyShowTeamId or curEnemyShowTeamId;
             MythicDungeonsProManager.heroDeadShow(data, teamType)
             --更新展示
             UIBattleMain.refreshHeroShow(data.teamId)
         elseif FightSelect.isShowSaveReport then
             if data.teamId == 1 then
                 local ctrl = this.skillBtnListByModelId[data.id]
                 if ctrl then
                     ctrl:GetController("state"):SetSelectedIndex(2);
                 end
             end
         end
     end

     function UIBattleMain.refreshIcons(info)
         if info.mySupSkill ~= 0 then
             local skillData = G.dataTable["t_skillshow"][tostring(info.mySupSkill)];
             if skillData then
                 mySkillIcon:GetChild("icon").url = "ui://SkillAtlas/" .. skillData.f_SkillIcon;
                 this.supSkillIcon:GetChild("icon").url = "ui://SkillAtlas/" .. skillData.f_SkillIcon;
                 Text_SupSkillName.text = skillData.f_SkillName;
             end
         end

         if FightManager.battleInfo.myHelpPartnerModelId then
             myHelpMan:GetChild("icon").url = "ui://ICONAtlas/" .. HeroManager.GetHeroIconByModelId(FightManager.battleInfo.myHelpPartnerModelId, FightManager.battleInfo.myHelpPartnerSkinId);
         end
         if FightManager.battleInfo.enemyHelpPartnerModelId then
             enemyHelpMan:GetChild("icon").url = "ui://ICONAtlas/" .. HeroManager.GetHeroIconByModelId(FightManager.battleInfo.enemyHelpPartnerModelId, FightManager.battleInfo.enemyHelpPartnerSkinId);
         end
         if info.enemySupSkill ~= 0 then
             local enemySkullData = G.dataTable["t_skillshow"][tostring(info.enemySupSkill)];
             if enemySkullData then
                 enemySkillIcon:GetChild("icon").url = "ui://SkillAtlas/" .. enemySkullData.f_SkillIcon;
             end
         end
     end

     function UIBattleMain.addEvent()
         btnPause.onClick:Add(this.onClickPause);
         btnPlay.onClick:Add(this.onClickPlay);
         --btnSpeed.onClick:Add(this.onClickSpeed);
         btnSpeed2.onClick:Add(this.onClickBtnSpeed2);
         btnSpeed3.onClick:Add(this.onClickBtnSpeed3);
         --[[屏蔽前端战斗btnAutoSkill.onClick:Add(this.automaticSkills);]]
    btnSkip.onClick:Add(this.onClickSkip);
    this.btnPetShow.onClick:Add(function()
        FightManager.paramTeamBonus.formationsIndex = BattlePlaybackManager.GetFightIndex();
        showUI(PanelNames.UITeamBonus, FightManager.paramTeamBonus);
    end);
    hideSkin.onClick:Add(function()
        if this.openGoldenFinger then
            FightManager.forceEndCommand();
        end

    end);

    this.btn_bullet_chat.onClick:Add(function()
        if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.BulletChat) then
            if this.cur_bullet_chat_open then
                this.cur_bullet_chat_open = false
                closeUI(PanelNames.UIBulletChat)
                this.bullet_mode_controller:SetSelectedIndex(1)
            else
                this.cur_bullet_chat_open = true
                showUI(PanelNames.UIBulletChat, 0)
                this.bullet_mode_controller:SetSelectedIndex(0)
            end
            local key = logicMgr.HeroManager.GetRoleId() .. "battlebullet_switch"
            Util.SetPlayerPrefs(key, tostring(this.cur_bullet_chat_open))
        end
    end)
    btnAuto.onClick:Add(function()
        if FuncOpenManager.isOpen(Config.FuncOpenType.autoAttack, true, btnAuto) then
            if not FightManager.autoJump then
                autoCtrl.selectedIndex = 1 - autoCtrl.selectedIndex
                local key = "UIBattleMainAuto" .. FightManager.fightType .. logicMgr.HeroManager.GetRoleInfo("playerId");
                if autoCtrl.selectedIndex == 1 then
                    FightManager.isAuto = true
                    if FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
                        SetPlayerPrefs("UIBattleMainAuto" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 1);
                    elseif FightManager.fightType == EnumConst.FightTypeConst.RealMan then
                        logicMgr.RealManWarManager.setPlayerOperationState(true);
                    elseif FightManager.fightType == EnumConst.FightTypeConst.TOWER then
                        key = key .. "_" .. logicMgr.TowerManager.getClimbType();
                        SetPlayerPrefs(key, 1);
                    else
                        SetPlayerPrefs(key, 1);
                    end
                    UISysTips.AddMsg(getLanguage("Character_Tips28"))
                else
                    FightManager.isAuto = nil
                    if FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
                        SetPlayerPrefs("UIBattleMainAuto" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 0);
                    elseif FightManager.fightType == EnumConst.FightTypeConst.RealMan then
                        logicMgr.RealManWarManager.setPlayerOperationState(false);
                    elseif FightManager.fightType == EnumConst.FightTypeConst.TOWER then
                        key = key .. "_" .. logicMgr.TowerManager.getClimbType();
                        SetPlayerPrefs(key, 0);
                    else
                        SetPlayerPrefs(key, 0);
                    end
                    UISysTips.AddMsg(getLanguage("Character_Tips29"))
                end
            end
        end
    end)
    btnEvent.onClick:Add(function()
        local popCtrl = CtrlManager.GetCtrl(PanelNames.UICommonPop)
        popCtrl.Init("126", function(b)
            if b then
                FightManager.isAuto = nil
                SetPlayerPrefs("UIBattleMainAuto" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 0);
                autoCtrl.selectedIndex = 0
                UISysTips.AddMsg(getLanguage("Character_Tips29"))
            end
        end);
    end)
end

function UIBattleMain.removeEvent()
    if btnAuto then
        btnAuto.onClick:Clear()
    end
    if btnEvent then
        btnEvent.onClick:Clear()
    end
    if btnPause then
        btnPause.onClick:Clear();
    end
    if btnPlay then
        btnPlay.onClick:Clear();
    end
    --btnSpeed.onClick:Clear();
    if btnSpeed2 then
        btnSpeed2.onClick:Clear();
    end
    if btnSpeed3 then
        btnSpeed3.onClick:Clear();
    end
    --[[屏蔽前端战斗 if btnAutoSkill then
         btnAutoSkill.onClick:Clear();
     end]]
     if btnSkip then
         btnSkip.onClick:Clear();
     end
     if hideSkin then
         hideSkin.onClick:Clear();
     end
     if this.btnPetShow then
         this.btnPetShow.onClick:Clear();
     end
     if this.btn_bullet_chat then
         --
         this.btn_bullet_chat.onClick:Clear()
     end
 end

 function UIBattleMain.ClearTimer()
     if FightManager.timerId then
         utimer.remove(FightManager.timerId)
         FightManager.timerId = nil
     end
 end

 function UIBattleMain.LocalListenEvent()
     ListenEvent(Config.EventType.Fresh_Skill, this.refreshSkill);
     ListenEvent(Config.EventType.Fight_Init, this.initHeroData);
     ListenEvent(Config.EventType.Fight_Update_BossHP, this.updateBossHP);
     ListenEvent(Config.EventType.Fight_Update_HeroHP, this.updateHeroHP);
     if FightSelect.isShowSaveReport then
         ListenEvent(Config.EventType.Fight_Update_HeroEnergy, this.updateHeroEnergy);
     end
     ListenEvent(Config.EventType.Fight_Dead_id, this.heroDeadShow);

     ListenEvent(Config.EventType.Fight_Update_Time, this.updateTime);
     --ListenEvent(Config.EventType.Fight_Begin, this.updateBegin);
     ListenEvent(Config.EventType.Fight_Finish, this.updateEnd);
     ListenEvent(Config.EventType.Fight_Update_CutIn, this.updateCutIn);
     ListenEvent(Config.EventType.Fight_HelpMan_Show, this.helpMamGery);
     ListenEvent(Config.EventType.Fight_HelpMan_Show_Skill, this.helpMamSkillGery);
     ListenEvent(Config.EventType.Fight_SupSkill_Show, this.showSupSkill);
     ListenEvent(Config.EventType.Fight_SupSkill_ui, this.doSupSkillTran);
     ListenEvent(Config.EventType.Fight_Kill_Show, this.killShow);
     ListenEvent(Config.EventType.PerformBattlePlay, this.performBattlePlay)
 end

 function UIBattleMain.LocalCloseEvent()
     CloseEvent(Config.EventType.Fresh_Skill, this.refreshSkill);
     CloseEvent(Config.EventType.Fight_Init, this.initHeroData);
     CloseEvent(Config.EventType.Fight_Update_BossHP, this.updateBossHP);
     CloseEvent(Config.EventType.Fight_Update_HeroHP, this.updateHeroHP);
     CloseEvent(Config.EventType.Fight_Update_Time, this.updateTime);
     if FightSelect.isShowSaveReport then
         CloseEvent(Config.EventType.Fight_Update_HeroEnergy, this.updateHeroEnergy);
     end

     --CloseEvent(Config.EventType.Fight_Begin, this.updateBegin);
     CloseEvent(Config.EventType.Fight_Finish, this.updateEnd);
     CloseEvent(Config.EventType.Fight_Update_CutIn, this.updateCutIn);
     CloseEvent(Config.EventType.Fight_HelpMan_Show, this.helpMamGery);
     CloseEvent(Config.EventType.Fight_HelpMan_Show_Skill, this.helpMamSkillGery);
     CloseEvent(Config.EventType.Fight_SupSkill_Show, this.showSupSkill);
     CloseEvent(Config.EventType.Fight_Dead_id, this.heroDeadShow);
     CloseEvent(Config.EventType.Fight_Dead_id, this.refreshGuildBossHeroShow);
     CloseEvent(Config.EventType.Fight_Kill_Show, this.killShow);
     CloseEvent(Config.EventType.Fight_SupSkill_ui, this.doSupSkillTran);
     CloseEvent(Config.EventType.PerformBattlePlay, this.performBattlePlay)
     logicMgr.FuncOpenManager.removeStatusCtr(PanelNames.UIBattleMain);

 end

 function UIBattleMain.OnDestroy()
     this.LocalCloseEvent() --
     this.ClearTimer()
     if eventTimeId then
         utimer.remove(eventTimeId)
         eventTimeId = nil
     end
     if this.hp1Timer then
         this.hp1Timer:Stop()
         this.hp1Timer = nil
     end
     if this.hp2Timer then
         this.hp2Timer:Stop()
         this.hp2Timer = nil
     end
     hasInit = false

     this.removeEvent();

     this.InitLocalData()

     this.btn_bullet_chat = nil
     this.bullet_chat_controller = nil
     this.bullet_mode_controller = nil

     this.trialsBuff = nil
 end

 function UIBattleMain.helpMamGery(team)
     if team == 1 then
         --this.myHeadLightSp.visible = true;
         myHelpMan:GetChild("icon").grayed = true;
         Util.AddAction(aidSkillBlueSpine, "idle", false, 0);
     elseif team == 2 then
         --this.enemyHeadLightSp.visible = true;
         enemyHelpMan:GetChild("icon").grayed = true;
         Util.AddAction(aidSkillRedSpine, "idle", false, 0);
     end
 end

 function UIBattleMain.showSupSkill(type, func)
     --upAni.spineAnimation.state.Data.SkeletonData:FindAnimation("idle2").Duration
     local fadeInTime = 0.25 * FightManager.curTimeScale;
     local fadeOutTime = 0.35 * FightManager.curTimeScale;
     supSkillType.selectedIndex = type;
     this.supSkillGroup.visible = true;
     if this.supHelpManSpine then
         local _skeletonGraphic = this.supHelpManSpine:GetComponent("SkeletonGraphic")
         _skeletonGraphic.color = UnityEngine.Color.New(1, 1, 1, 0);

         _skeletonGraphic.AnimationState:SetAnimation(0, "idle2", true);
         local timeAdd = 0;
         if fade == 0 then
         else
             timeAdd = fadeOutTime;
         end

         local frameFunc = function(obj, fade, frame, func)

             local _skeletonGraphic = obj:GetComponent("SkeletonGraphic")
             local fadeFunc = function()
                 if fade == 1 then
                     timeAdd = timeAdd + Time.deltaTime;
                 else
                     timeAdd = timeAdd - Time.deltaTime;
                 end
                 if fade == 1 then
                     if timeAdd >= frame then
                         _skeletonGraphic.color = UnityEngine.Color.New(_skeletonGraphic.color.r, _skeletonGraphic.color.g, _skeletonGraphic.color.b, 1);
                         if func then
                             func()
                         end
                         return
                     end
                 else
                     if timeAdd <= frame then
                         _skeletonGraphic.color = UnityEngine.Color.New(_skeletonGraphic.color.r, _skeletonGraphic.color.g, _skeletonGraphic.color.b, 0);
                         if func then
                             func()
                         end
                         return
                     end
                 end
                 _skeletonGraphic.color = UnityEngine.Color.New(_skeletonGraphic.color.r, _skeletonGraphic.color.g, _skeletonGraphic.color.b, timeAdd / frame);
             end
             FightManager.addUpdateFuncs(fadeFunc, frame * 1000, true)
         end
         this.utimerLiHuiFade = frameFunc(this.supHelpManSpine, 1, fadeInTime, function()
             FightManager.addDelayFuncs(function()
                 this.utimerLiHuiFade = frameFunc(this.supHelpManSpine, 0, fadeOutTime)
             end, 600, true);
         end)
     end
     helpSkillTran:Play(func);
 end

 function UIBattleMain.doSupSkillTran(type)
     supSkillTran:Play(func);
 end

 function UIBattleMain.helpMamSkillGery(team)
     --upAni.spineAnimation.state.Data.SkeletonData:FindAnimation("idle2").Duration
     if team == 1 then
         --local skillAniState = helpSkillSpine.spineAnimation.state;
         --skillAniState:SetAnimation(0, "idle", false);
         mySkillIcon:GetChild("icon").grayed = true;
         Util.AddAction(this.effYZSkillBlueSpine, "idle", false, 0);
     elseif team == 2 then
         enemySkillIcon:GetChild("icon").grayed = true;
         Util.AddAction(this.effYZSkillRedSpine, "idle", false, 0);
     end
 end

 function UIBattleMain.OnEnable()
     logicMgr.ArenaManager.setSomeBattleSkip(false);
     this.LocalListenEvent();
     delayDisableCamera = false
     if FightManager.fightType == EnumConst.FightTypeConst.INSTANCE then
         this.refreshHeroShow()
     elseif FightManager.fightType == EnumConst.FightTypeConst.TRIAL then
         this.showTrialsBuff()
     end
     if battleRoundRoot ~= nil then
         battleRoundRoot.gameObject:SetActive(true);
         if roundCamera ~= nil then
             FightManager.setCamera(roundCamera);
         end
     end
     this.updateBossHP(0)
 end

 --- 禁用战斗场景摄像机
 --- @private
 function UIBattleMain.DisableCamera()
     if not delayDisableCamera then
         return
     end

     delayDisableCamera = false

     local temp = panelMgr.BattleRound
     if temp ~= nil then
         temp.gameObject:SetActive(false);
     end
 end

 function UIBattleMain.OnDisable()
     if eventTimeId then
         utimer.remove(eventTimeId)
         eventTimeId = nil
     end
     this.ClearTimer()
     this.LocalCloseEvent();
     rightSlider.value = 100;
     leftSlider.value = 100;
     rightHP.text = "100%";
     leftHP.text = "100%";
     this.cutInPos = 0;

     mainTime.text = timeToTimeFormat_MS(logicMgr.MapManager.getMaxTime());
     trialScore = 0;
     allDamage = 0;
     if this.killListRefreshUTimer then
         ubattletimer.remove(this.killListRefreshUTimer);
         this.killListRefreshUTimer = nil;
     end
     if this.cutInEff_B then
         destroyImmediate(this.cutInEff_B);
     end
     if this.cutInEff_F then
         destroyImmediate(this.cutInEff_F);
     end
     if this.effKaizhanSprine then
         destroyImmediate(this.effKaizhanSprine);
     end
     if this.aidSkillBlueSpine then
         destroyImmediate(this.aidSkillBlueSpine);
     end
     if this.aidSkillRedSpine then
         destroyImmediate(this.aidSkillRedSpine);
     end
     if this.effYZSkillBlueSpine then
         destroyImmediate(this.effYZSkillBlueSpine);
     end
     if this.effYZSkillRedSpine then
         destroyImmediate(this.effYZSkillRedSpine);
     end
     if this.supSkillBackSpine then
         destroyImmediate(this.supSkillBackSpine);
     end
     if this.supSkillFrontSpine then
         destroyImmediate(this.supSkillFrontSpine);
     end
     if this.supHelpManSpine then
         destroyImmediate(this.supHelpManSpine);
     end
     if this.drawWrappers then
         for key, value in pairs(drawWrappers) do
             value:SetWrapTarget(nil, false)
         end
     end
     if this.soloBossUTimer then
         ubattletimer.remove(this.soloBossUTimer);
         this.soloBossUTimer = nil;
     end
     delayDisableCamera = true
     -- 下一帧禁用
     utimer.delayCall(this.DisableCamera, 0)

     skipCount = 0;
 end

 function UIBattleMain.onClickPause()
     btnPause.visible = false;
     btnPlay.visible = true;
     Time.timeScale = 0;
     AudioManager.Play(7001)
     --logMy('onClickPause', Time.timeScale);
     -- 暂停时关闭弹幕
     if Config.OpenCommentAndBullet and BattlePlaybackManager.cur_play_fight_type
             and BattlePlaybackManager.cur_play_fight_type == EnumConst.FightTypeConst.TOWER then
         if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.BulletChat) then
             if this.cur_bullet_chat_open then
                 this.cur_bullet_chat_open = false
                 closeUI(PanelNames.UIBulletChat)
                 this.bullet_mode_controller:SetSelectedIndex(1)
             end
         end
     end

 end

 function UIBattleMain.onClickPlay()
     if btnPause then
         btnPause.visible = true;
         btnPlay.visible = false;
         Time.timeScale = FightManager.curTimeScale;
     end
     --logMy('onClickPlay', Time.timeScale);
 end
 function UIBattleMain.automaticSkills(e, isInit)
     if isInit then
     else
         if FightManager.isAutoSkill then
             autoSkillCtrl.selectedIndex = 0;
             FightManager.isAutoSkill = false;
         else
             autoSkillCtrl.selectedIndex = 1;
             FightManager.isAutoSkill = true;

             if FightManager.curTimeScale == FightManager.timeScaleLv_3 then
                 this.onClickBtnSpeed2()
             end
         end
     end
     SetPlayerPrefs("autoSkill" .. logicMgr.HeroManager.GetRoleInfo("playerId"), tostring(FightManager.isAutoSkill and "1" or "0"))
     autoSkillCtrl.selectedIndex = FightManager.isAutoSkill and 1 or 0;

 end

 function UIBattleMain.onClickBtnSpeed2(e)
     if not FightManager.entranceFinish and e then
         return
     end

     --编辑器模式
     if HeroManager.GetRoleId() == "" then
         if FightManager.curTimeScale ~= FightManager.timeScaleLv_2 then
             btnSpeed2:GetController("effect").selectedIndex = 1;
             btnSpeed3:GetController("effect").selectedIndex = 0;

             FightManager.curTimeScale = FightManager.timeScaleLv_2;
             if e then
                 FightManager.setSkillEffectTimeScale();
             end

             AudioManager.SetRTPCValue("game_speed", (100 / FightManager.curTimeScale))
             SetPlayerPrefs("UIBattleMainSpeed" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 1);

             if Time.timeScale > 0 then
                 Time.timeScale = 1;
                 Time.timeScale = FightManager.curTimeScale;
             end
         else
             this.onClickBtnSpeed1();
         end
         return
     end

     if FuncOpenManager.isOpen(Config.FuncOpenType.BattleSpeed, true, btnSpeed2) and not FightManager.cutInState then
         if FightManager.curTimeScale ~= FightManager.timeScaleLv_2 then

             local typeId, grayId, lockId = logicMgr.FuncOpenManager.checkStatus(Config.FuncOpenType.BattleSpeed);
             btnSpeed2:GetController("effect").selectedIndex = 0;
             if typeId ~= 0 then
                 if not isEnter then
                     UISysTips.AddMsg(getLanguage("Character_Tips23"));
                 end
                 return ;
             else
                 if not isEnter then
                     UISysTips.AddMsg(getLanguage("Character_Tips16"));
                 end
             end

             btnSpeed2:GetController("effect").selectedIndex = 1;
             btnSpeed3:GetController("effect").selectedIndex = 0;

             --btnSpeed2.selected  = true;
             --btnSpeed3.selected  = false;

             FightManager.curTimeScale = FightManager.timeScaleLv_2;
             if e then
                 FightManager.setSkillEffectTimeScale();
             end
             AudioManager.SetRTPCValue("game_speed", (100 / FightManager.curTimeScale))
             SetPlayerPrefs("UIBattleMainSpeed" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 1);

             if Time.timeScale > 0 then
                 Time.timeScale = 1;
                 Time.timeScale = FightManager.curTimeScale;
             end
         end
         elseif HeroManager.GetRoleId() ~= "" then
         this.onClickBtnSpeed1();
     end


     --logMy('onClickSpeed', Time.timeScale);
 end

 function UIBattleMain.onClickBtnSpeed3(e)
     if not FightManager.entranceFinish and e then
         return
     end
     --编辑器模式
     if HeroManager.GetRoleId() == "" then
         if FightManager.curTimeScale ~= FightManager.timeScaleLv_3 then
             btnSpeed2:GetController("effect").selectedIndex = 0;
             btnSpeed3:GetController("effect").selectedIndex = 1;
             FightManager.curTimeScale = FightManager.timeScaleLv_3;
             if FightManager.isAutoSkill then
                 ----设置5倍速取消自动技能
                 --[[屏蔽前端战斗  this.automaticSkills()]]
               end
               if e then
                   FightManager.setSkillEffectTimeScale();

               end

               AudioManager.SetRTPCValue("game_speed", (100 / FightManager.curTimeScale))
               SetPlayerPrefs("UIBattleMainSpeed" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 2);

               if Time.timeScale > 0 then
                   Time.timeScale = FightManager.curTimeScale;
               end
           else
               this.onClickBtnSpeed1();
           end
           return
       end

       if FuncOpenManager.isOpen(Config.FuncOpenType.BattleSpeed_5, true, btnSpeed3) and not FightManager.cutInState then
           if FightManager.curTimeScale ~= FightManager.timeScaleLv_3 then
               local typeId, grayId, lockId = logicMgr.FuncOpenManager.checkStatus(Config.FuncOpenType.BattleSpeed_5);

               if typeId ~= 0 then
                   --5倍速没开，提示没开
                   if not isEnter then
                       UISysTips.AddMsg(getLanguage("Character_Tips24"));
                   end
                   return ;
               else
                   --btnSpeed2.selected  = false;
                   --btnSpeed3.selected  = true;
                   btnSpeed2:GetController("effect").selectedIndex = 0;
                   btnSpeed3:GetController("effect").selectedIndex = 1;
                   --提示进入
                   if not isEnter then
                       UISysTips.AddMsg(getLanguage("Character_Tips22"));
                   end

               end
               FightManager.curTimeScale = FightManager.timeScaleLv_3;
               if e then
                   FightManager.setSkillEffectTimeScale();
               end

               AudioManager.SetRTPCValue("game_speed", (100 / FightManager.curTimeScale))
               SetPlayerPrefs("UIBattleMainSpeed" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 2);

               if Time.timeScale > 0 then
                   Time.timeScale = FightManager.curTimeScale;
               end
           elseif HeroManager.GetRoleId() ~= "" then

               this.onClickBtnSpeed1();
           end
       end


       --logMy('onClickSpeed2', Time.timeScale);
   end
   function UIBattleMain.onClickBtnSpeed1(e)
       if not isEnter then
           UISysTips.AddMsg(getLanguage("Character_Tips15"));
       end

       --btnSpeed2.selected = false;
       --btnSpeed3.selected = false;
       btnSpeed2:GetController("effect").selectedIndex = 0;
       btnSpeed3:GetController("effect").selectedIndex = 0;
       SetPlayerPrefs("UIBattleMainSpeed" .. logicMgr.HeroManager.GetRoleInfo("playerId"), 0);
       FightManager.curTimeScale = FightManager.timeScaleLv_1;
       if e then
           FightManager.setSkillEffectTimeScale();
       end

       AudioManager.SetRTPCValue("game_speed", (100 / FightManager.curTimeScale))
       if Time.timeScale > 0 then
           Time.timeScale = FightManager.curTimeScale;
           FightManager.frameRender = FightManager.frame
       end
       --logMy('onClickSpeed2', Time.timeScale);
   end

   function UIBattleMain.onClickSkip()
       --回放无跳过限制
       if BattlePlaybackManager.GetIsRecord() == 1 then
           this.clickSkip()
       else
           if FuncOpenManager.isOpen(this.getSkipFuncOpenType(), true, btnSkip) and FightManager.entranceFinish then
               if FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
                   if (not this.checkDungeonSkip(true)) then
                       return
                   end
               end
               this.clickSkip()
           end
       end
   end

   function UIBattleMain.checkDungeonSkip(flag)
       if HeroManager.GetRoleId() ~= "" then
           --printError("========================",logicMgr.MapManager.GetBattleBeforeMapId())
           local key = "DUNGEON_skip" .. logicMgr.MapManager.GetAutoMapId();
           local value = tonumber(GetPlayerPrefs(key) or 0);
           local max = dataTable.getGlobalInt(579) or 0
           if max >= 0 and value >= max then
               if flag then
                   UISysTips.AddMsg(getLanguage("FunctionOpenDesLimitTips602"));
               end
               return false;
           else
               if flag then
                   SetPlayerPrefs(key, value + 1)
               end
               return true;
           end
       else
           return true;
       end
   end
   function UIBattleMain.clickSkip()
       if skipCount ~= 0 then
           return ;
       end
       skipCount = 1;
       if FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
           if FightManager.AutoGoFight() then
               this.ClearTimer()
               local count = 0
               FightManager.timerId = utimer.timeCall(function()
                   count = count + 1
                   if count >= 5 then
                       utimer.remove(FightManager.timerId)
                       FightManager.timerId = nil
                       if skipCount ~= 0 then
                           return ;
                       end
                       skipCount = 1;
                       local showTip = BattlePlaybackManager.GetIsRecord() == 0;
                       FightManager.forceEndCommand();
                   end
               end, 1000, -1)
               return
           end
       elseif FightManager.fightType == EnumConst.FightTypeConst.StoryBattle then
           if FightManager.AutoGoFight(EnumConst.FightTypeConst.StoryBattle) then
               logicMgr.StoryHardManager.autoBattle();
               this.ClearTimer()
               FightManager.timerId = utimer.timeCall(function()
                   FightManager.timerId = nil
                   if this.isShowResultUI then
                       return
                   end
                   this.isShowResultUI = true
                   FightManager.forceEndCommand();
                   FightManager.showResultUI()
               end, 3000, 1)
               return
           end
       end
       local showTip = BattlePlaybackManager.GetIsRecord() == 0;
       FightManager.forceEndCommand();
   end

   function UIBattleMain.onBattleFinish()
       this.uploadReport();
       --FightManager.leaveFight();


       if BattlePlaybackManager.getBattleResult() == 1 then
           -- Util.WaitForSeconds(function()
           --     this.showResultUI()
           -- end, 1.5);
           this.DelayShowResultUI()
       else
           -- Util.WaitForSeconds(function()
           --     --this.playCVSound(CVType.FAILURE);
           --     this.showResultUI()
           -- end, 1.5);
           this.DelayShowResultUI()
       end
   end

   function UIBattleMain.DelayShowResultUI()
       utimer.delayCall(function()
           this.showResultUI()

       end, 1200)
   end

   function UIBattleMain.showResultUI()
       if FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
           local nowStage = logicMgr.MapManager.getMapId();
           local cfg = G.dataTable["t_stage"][tostring(nowStage)]
           if cfg.f_NextStage ~= -1 then
               local battle_result = BattlePlaybackManager.getBattleResult()
               if battle_result == 1 then
                   if FightManager.isAuto then
                       if logicMgr.MapManager.GetIsCanSkip() then
                           local mapConfig = logicMgr.MapManager.GetMapcfgByID(nowStage);
                           if mapConfig ~= nil and not logicMgr.MapManager.IsEndChapterMapId(nowStage) then
                               if mapConfig.f_SkipStageTarget > nowStage and (not logicMgr.GuideMgr.HasGuidingInRankLevel(nowStage, mapConfig.f_SkipStageTarget))
                                       and (not logicMgr.StoryMgr.HasStoryInRankLevel(nowStage, mapConfig.f_SkipStageTarget)) then
                                   FightManager.autoJump = true
                                   dungeonHandler.sendReqSkipDungeon()
                                   return
                               end
                           end
                       else
                           if FightManager.AutoGoFight() then
                               this.ClearTimer()
                               local count = 0
                               FightManager.timerId = utimer.timeCall(function()
                                   count = count + 1
                                   if count >= 3 then
                                       utimer.remove(FightManager.timerId)
                                       FightManager.timerId = nil
                                       if this.soloBossUTimer then
                                           ubattletimer.remove(this.soloBossUTimer);
                                           this.soloBossUTimer = nil;
                                       end
                                       if this.isShowResultUI then
                                           return
                                       end
                                       this.isShowResultUI = true
                                       FightManager.showResultUI()
                                   end
                               end, 1000, -1)
                               return
                           end
                       end
                   end
               else
                   FightManager.isAuto = nil
                   FightManager.battleFunction = nil
               end
           end
       elseif FightManager.fightType == EnumConst.FightTypeConst.RealMan then
           if FightManager.isAuto then
               if isOpenUI(PanelNames.UITeamBonus) then
                   closeUI(PanelNames.UITeamBonus);
               end
               if isOpenUI(PanelNames.UIFuncOpenView) then
                   closeUI(PanelNames.UIFuncOpenView);
               end
               if this.soloBossUTimer then
                   ubattletimer.remove(this.soloBossUTimer);
                   this.soloBossUTimer = nil;
               end
               FightManager.IsBattleFight = false;
               Time.timeScale = 1;
               --FightManager.destroy();
               local battleResult = logicMgr.RealManWarManager.getFightResult();
               if battleResult ~= nil and battleResult.fightResult == 1 then
                   logicMgr.RealManWarManager.OpenSoloBattle(3);
                   this.ClearTimer()
                   local count = 0
                   FightManager.timerId = utimer.timeCall(function()
                       count = count + 1
                       if count >= 3 then
                           this.ClearTimer();
                           if this.isShowResultUI then
                               return ;
                           end
                           this.isShowResultUI = true;
                           FightManager.showResultUI();
                       end
                   end, 1000, -1);
                   return ;
               end
           end
       elseif FightManager.fightType == EnumConst.FightTypeConst.TOWER then
           if FightManager.AutoGoFight(EnumConst.FightTypeConst.TOWER) then
               if logicMgr.TowerManager.getIsCanSkip() then
                   local towerType = logicMgr.TowerManager.getClimbType();
                   local layerData = logicMgr.TowerManager.returnTowerInfo(towerType);
                   local layerId = layerData.layerId - 1;
                   local skipLayerId = logicMgr.TowerManager.getTowerJumpLayer(towerType, layerId);
                   local layerLimit = logicMgr.TowerManager.getAdvancedTowerToDayLimit(towerType);
                   local skipLayer = math.min(skipLayerId, layerId + layerLimit - layerData.todayLayer + 1);
                   if skipLayer > layerId + 1 then
                       FightManager.autoJump = true;
                       logicMgr.TowerManager.addLayer(towerType, skipLayer);
                       towerHandler.sendTowerJump(towerType);
                       this.ClearTimer();
                       local count = 0;
                       FightManager.timerId = utimer.timeCall(function()
                           count = count + 1
                           if count >= 3 then
                               this.ClearTimer();
                               if this.isShowResultUI then
                                   return ;
                               end
                               this.isShowResultUI = true;
                               FightManager.showResultUI();
                           end
                       end, 1000, -1);
                       return ;
                   end
               else
                   logicMgr.TowerManager.towerAutoBattle();
                   this.ClearTimer();
                   local count = 0;
                   FightManager.timerId = utimer.timeCall(function()
                       count = count + 1
                       if count >= 3 then
                           this.ClearTimer();
                           if this.isShowResultUI then
                               return ;
                           end
                           this.isShowResultUI = true;
                           FightManager.showResultUI();
                       end
                   end, 1000, -1);
                   return ;
               end
           else
               FightManager.isAuto = nil;
               FightManager.battleFunction = nil;
           end
       elseif FightManager.fightType == EnumConst.FightTypeConst.StoryBattle then
           if FightManager.AutoGoFight(EnumConst.FightTypeConst.StoryBattle) then
               logicMgr.StoryHardManager.autoBattle();
               this.ClearTimer()
               FightManager.timerId = utimer.timeCall(function()
                   FightManager.timerId = nil
                   if this.soloBossUTimer then
                       ubattletimer.remove(this.soloBossUTimer);
                       this.soloBossUTimer = nil;
                   end
                   if this.isShowResultUI then
                       return
                   end
                   this.isShowResultUI = true
                   FightManager.showResultUI()
               end, 3000, 1)
               return
           else
               FightManager.isAuto = nil
               FightManager.battleFunction = nil
           end
       end
       --collectgarbage("collect")
       if this.soloBossUTimer then
           ubattletimer.remove(this.soloBossUTimer);
           this.soloBossUTimer = nil;
       end
       if this.isShowResultUI then
           return
       end
       this.isShowResultUI = true
       FightManager.showResultUI()
   end

   function UIBattleMain.playCVSound(soundtype, conprof)
       --[[
       local roundnum = Mathf.Random(1,2);
       local prof = conprof;
       if conprof == nil then
           if MercenaryModel.fightID ~= nil and roundnum > 1.5 then
               local mercendata = MercenaryModel.mercenSotreList[MercenaryModel.fightID];
               prof = mercendata.partnerModelId;
           else
               prof = logicMgr.HeroManager.GetRoleInfo().leaderModelId;
           end
       end

       local cvsound = string_split(G.dataTable["t_hero"][tostring(prof)][soundtype],",");
       local roundnum = Mathf.Round(Mathf.Random(1,#cvsound));
       local soundpath = "sound/cv/hero_"..prof.."/"..cvsound[roundnum];
       if cvsound[roundnum] ~= nil and cvsound[roundnum] ~= "" then
           soundMgr:PlayCV(soundpath,nil);
       end
       ]]
end

function UIBattleMain.updateBossHP(damage)
    local maxHP = 0;
    local hp = 0;
    if this.typeController and (this.typeController.selectedIndex == 4 or this.typeController.selectedIndex == 1 or this.typeController.selectedIndex == 7) then
        if this.typeController.selectedIndex ~= 7 then
            this.getMaxHp = function()
                maxHP = 0;
                for i = 1, 5 do
                    --风暴峡湾boss
                    local bossCfg = logicMgr.TrialsManager.GetBossConfigByIdAndLevel(battleInfo.trialId, curLevel);

                    if this.typeController.selectedIndex == 4 then
                        --工会boss
                        bossCfg = GuildManager.GetBossConfigByIdAndLevel(GuildManager.getGuideBossCfg().f_Id, curLevel)
                    end
                    if bossCfg then
                        local cfg = decodeJsonStrToTabel(bossCfg["f_MonsterPara" .. i]);
                        if cfg then
                            maxHP = maxHP + cfg[3][2];
                        end
                    else
                        --printError("bossCfg is nil,trialId=, level=", battleInfo.trialId, curLevel)
                        return
                    end

                end
            end
            this.getMaxHp()
            this.checkCurLevel = function()
                if trialScore > maxHP then
                    curLevel = curLevel + 1
                    trialScore = trialScore - maxHP;
                    this.getMaxHp()
                    if trialScore >= maxHP then
                        this.checkCurLevel()
                    end
                end
                if this.typeController.selectedIndex == 4 then
                    this.boxNum.text = curLevel;
                    bossBuff:GetChild("level").text = tostring(curLevel);
                elseif this.typeController.selectedIndex == 1 then
                    bossBuff:GetChild("level").text = tostring(curLevel);

                end
            end
        else
            --心之试炼boss
            maxHP = logicMgr.SoloChaosTestManager.getMaxHp();

            for i = 1, #FightManager.fighterList do
                local fighter = FightManager.fighterList[i];
                if fighter.teamIndex == 2 and fighter.isHero then
                    if not fighter:getDeadState() and not fighter.isEmpty then
                        hp = fighter.hp;
                    end
                end
            end

            local bloodBarNum = G.dataTable["t_global"]["617"].f_int_value;
            local newBloodBarNum = hp / bloodBarNum;
            local curBloodHp = math.fmod(hp, bloodBarNum);--当前血条血量
            this.startBloodNum = math.fmod(maxHP, bloodBarNum);
            this.curBloodBarNum = math.floor(hp / bloodBarNum);
            if this.curShowBloodBarNum == -1 and hp ~= 0 then
                this.curShowBloodBarNum = this.curBloodBarNum;
                this.soloBossBloodBarText.text = "X " .. this.curShowBloodBarNum;--血条数值
            end
            if maxHP - hp <= this.startBloodNum or maxHP - hp == 0 then
                curBloodHp = bloodBarNum + curBloodHp;
                bloodBarNum = bloodBarNum + math.fmod(maxHP, bloodBarNum);
            end
            this.curBloodBarValue = curBloodHp / bloodBarNum * 100;
            this.allSoloBossBloodBar.value = (hp / maxHP) * 100;--总血条com
            --this.soloBossBloodBar.value = (math.fmod(hp, G.dataTable["t_global"]["617"].f_int_value) / bloodBarNum) * 100;--血条com

        end
        if damage then
            allDamage = allDamage + damage;
            trialScore = trialScore + damage;
            if this.typeController.selectedIndex == 7 then
                this.soloBossDamageText.text = string.format(getLanguage("SoloChaosTestTips07"), allDamage);
                if logicMgr.SoloChaosTestManager.getNowBossId() == logicMgr.SoloChaosTestManager.getEndLessBossId() then
                    local barItem = UIPackage.CreateObject("UIBattleMain", "Com_BossHp");
                    barItem.visible = true;
                    barItem:SetXY(this.hpBar.x, this.hpBar.y)
                    local effectTexts = {}
                    this.gameObject:AddChild(barItem);
                    table.insert(this.soloBossEffectTexts, barItem);
                    for i = 1, 15 do
                        local num = "0";
                        if i < 10 then
                            num = num .. i;
                        else
                            num = i;
                        end
                        local text = barItem:GetChild("Text_NormalDamage" .. num)
                        table.insert(effectTexts, text);
                    end

                    local strAllDamage = tostring(allDamage);
                    local strList = {};
                    local split = function(str)
                        -- body
                        strList = {}
                        for i = string.len(str), 1, -1 do
                            table.insert(strList, tonumber(string.sub(str, i, i)))
                        end
                        return strList
                    end
                    split(strAllDamage);
                    for i = 1, 15 do
                        local idx = 16 - i;
                        if strList[i] then
                            effectTexts[idx].visible = true;
                            effectTexts[idx].text = strList[i];
                        else
                            effectTexts[idx].visible = false;
                        end
                    end
                    barItem:GetTransition("shake"):Play();
                    barItem:GetTransition("zoom"):Play();
                    if table.getn(this.soloBossEffectTexts) > 1 then
                        local destroyItem = this.soloBossEffectTexts[1];
                        table.remove(this.soloBossEffectTexts, 1)
                        destroyItem:GetTransition("fade"):Play(function()
                            destroyItem:Dispose()
                        end);
                    end
                end
            end
        end
        if this.typeController and this.typeController.selectedIndex == 4 then
            --工会boss
            if trialScore > maxHP then
                this.checkCurLevel();
            else
                if maxHP > 0 then
                    bossBloodBar.value = (trialScore / maxHP) * 100;
                else
                    bossBloodBar.value = 0;
                end

            end
            local allMaxHp = 0;
            for i = 1, curLevel do
                local cfgLevel = GuildManager.GetBossConfigByIdAndLevel(GuildManager.getGuideBossCfg().f_Id, i)
                for j = 1, 5 do
                    local maxHpStage = decodeJsonStrToTabel(cfgLevel["f_MonsterPara" .. j]);
                    if maxHpStage then
                        allMaxHp = allMaxHp + maxHpStage[3][2];
                    end
                end
            end
            bossHpText.text = allDamage .. "/" .. allMaxHp;
        elseif this.typeController and this.typeController.selectedIndex == 1 then
            if trialScore > maxHP then
                this.checkCurLevel();
            else
                if maxHP > 0 then
                    bossBloodProgressBar.value = (trialScore / maxHP) * 100;
                else
                    bossBloodProgressBar.value = 0;
                end

            end
            bossDamageText.text = allDamage;
        end
        --maxHP
    else
        for i = 1, #FightManager.fighterList do
            local fighter = FightManager.fighterList[i];
            if fighter.teamIndex == 2 and fighter.isHero then
                maxHP = maxHP + fighter.maxHP;
                if not fighter:getDeadState() and not fighter.isEmpty then
                    hp = hp + fighter.hp;
                end
            end
        end
        if this.rightSlider then
            if maxHP > 0 then
                this.rightSlider.value = (hp / maxHP) * 100;
            else
                this.rightSlider.value = 0;
            end

            if this.rightSlider.value == 100 and rightSlider2 ~= nil then
                rightSlider2.value = 100;
            end
        end
        if this.rightHP then
            if hp <= 0 or maxHP <= 0 then
                this.rightHP.text = 0 .. "%";
            else
                this.rightHP.text = Mathf.Ceil((hp / maxHP) * 100) .. "%";
            end
        end
        local delta = 0
        if maxHP > 0 then
            if rightSlider2 ~= nil then
                delta = rightSlider2.value - (hp / maxHP) * 100
            end
        end

        if this.hp2Timer == nil then
            this.hp2Timer = Timer.New(function()
                if rightSlider2 ~= nil then
                    rightSlider2.value = rightSlider2.value - (delta / 20)
                end
            end, BloodTime / 20, 20);
        else
            this.hp2Timer:Reset(function()
                if rightSlider2 ~= nil then
                    rightSlider2.value = rightSlider2.value - (delta / 20)
                end
            end, BloodTime / 20, 20);
        end
        this.hp2Timer:Start();
    end
end
function UIBattleMain.updateHeroEnergy(entity, num)
    if entity.teamIndex == 1 then
        local item = this.skillBtnListByModelId[entity.partnerModelId];
        if item then
            if num <= 100 then
                item:GetChild("energy"):TweenValue(num * 100, 0.3);
            else
                item:GetChild("energy").value = 100;
            end

        end
    end
end

function UIBattleMain.updateHeroHP()
    if FightManager.fightType == EnumConst.FightTypeConst.GuildBoss then
        --for i = 1, #FightManager.fighterList do
        --    local fighter = FightManager.fighterList[i];
        --    if fighter.teamIndex == 1 then
        --        local item = this.mainFormationListCom[fighter.partnerModelId];
        --        if not item then
        --            item = this.helpFormationListCom[fighter.partnerModelId];
        --        end
        --
        --        if item then
        --            local maxHP = fighter.maxHP;
        --            local hp = fighter.hp;
        --
        --            item.progress.value = (1 - hp / maxHP) * 100;
        --            item.hpPercentage.text = math.ceil((hp / maxHP) * 100 ).. "%";
        --        end
        --    end
        --end
    else
        local maxHP = 0;
        local hp = 0;
        for i = 1, #FightManager.fighterList do
            local fighter = FightManager.fighterList[i];
            if fighter.teamIndex == 1 and fighter.isHero then
                maxHP = maxHP + fighter.maxHP;
                if not fighter:getDeadState() and not fighter.isEmpty then
                    hp = hp + fighter.hp;
                end
            end
        end
        if maxHP > 0 then
            leftSlider.value = (hp / maxHP) * 100;
        else
            leftSlider.value = 0;
        end

        if leftSlider.value == 100 then
            leftSlider2.value = 100;
        end

        if hp <= 0 or maxHP <= 0 then
            leftHP.text = 0 .. "%";
        else
            leftHP.text = Mathf.Ceil(hp / maxHP * 100) .. "%";
        end
        local delta = 0;
        if maxHP > 0 then
            delta = leftSlider2.value - (hp / maxHP * 100);
        end

        if this.hp1Timer == nil then
            this.hp1Timer = Timer.New(function()
                leftSlider2.value = leftSlider2.value - (delta / 20);
            end, BloodTime / 20, 20);
        else
            this.hp1Timer:Reset(function()
                leftSlider2.value = leftSlider2.value - (delta / 20);
            end, BloodTime / 20, 20);
        end
        this.hp1Timer:Start();
    end
end

function UIBattleMain.updateBegin()
    if effKaizhan then
        effKaizhan.visible = true;
        --playUISpineAnimation(effKaizhan);
        -- Util.WaitForSeconds(function()
        --     effKaizhan.visible = false;
        -- end, 1);
        ubattletimer.delayCall(function()
            effKaizhan.visible = false;
        end, 900)
    end
end

function UIBattleMain.updateEnd(forceEnd)
    -- 强制结束时，直接弹出结算ui
    this.cur_bullet_chat_open = false

    local ui_bulletchat = CtrlManager.GetCtrl(PanelNames.UIBulletChat)
    if ui_bulletchat ~= nil then
        ui_bulletchat.StopTimer()
    end
    DestoryUI(PanelNames.UIBulletChat)
    BattlePlaybackManager.cur_play_fight_type = nil

    if forceEnd then
        this.uploadReport();
        --FightManager.leaveFight();
        this.showResultUI()
        return
    end
    if typeController.selectedIndex == 1 and FightManager.isRePlay == false then
        --战斗结束加上血统等于对boss的伤害
        local curDamage = tonumber(bossDamageText.text);
        local info = logicMgr.TrialsManager.GetBattleInfo();
        local damage = tonumber(info.damage) - curDamage
        if damage > 0 then
            this.updateBossHP(damage)
        end
    end
    this.onBattleFinish();
end

function UIBattleMain.updateCutIn(modelId)
    if modelId == "610" then
        modelId = "61"
    end
    local heroCfig = G.dataTable["t_hero"][tostring(modelId)];
    local effCutinLeft = this.cutInItems;
    if effCutinLeft ~= nil and heroCfig ~= nil then
        local effCutinLeft_c = this.cutInEff_C;
        local effCutinLeft_fSprine = this.cutInEff_F;
        local effCutinLeft_bSprine = this.cutInEff_B;

        --必杀技横幅
        local _skillInfo = G.dataTable["t_skillinfo"][tostring(heroCfig["f_HeroSkill1"])]
        if _skillInfo then
            local _skillVoiceIndex = 11 + _skillInfo.f_SkillType
            local _interactionTag = AudioManager.InteractionTagTable[_skillVoiceIndex].Tag
            local _skinId = 0
            AudioManager.PlayInteractionVoice(modelId, _skinId, _interactionTag, nil, nil, true)
            --AudioManager.Play(3007)

            effCutinLeft.visible = true;
            local halfBodyIcon = effCutinLeft_c:GetChild("n3");
            halfBodyIcon.url = "ui://HalfHeadAtlas/hero_halfhead_" .. modelId;
            local skillNameText = effCutinLeft_c:GetChild("skillName");
            skillNameText.text = getLanguage(_skillInfo.f_SkillName);
            local ani = effCutinLeft_c:GetTransition("move");
            ani.ignoreEngineTimeScale = false;

            AudioManager.Play(1055)

            Util.AddAction(effCutinLeft_fSprine, "idle", false, 0);

            Util.AddAction(effCutinLeft_bSprine, "idle", false, 0);
            ani:Stop()
            ani:Play(function()
                UIBattleMain.UpdateCutInComplete();
            end)
        else
            effCutinLeft.visible = false;
        end
    else
        effCutinLeft.visible = false;
    end
end

function UIBattleMain.UpdateCutInComplete()
    this.cutInItems.visible = false;
end

function UIBattleMain.initHeroData()

    if Config.OpenCommentAndBullet then
        if BattlePlaybackManager.cur_play_fight_type and BattlePlaybackManager.cur_play_fight_type == EnumConst.FightTypeConst.TOWER then
            if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.BulletChat) then
                this.bullet_chat_controller:SetSelectedIndex(0)
                local key = logicMgr.HeroManager.GetRoleId() .. "battlebullet_switch"
                local battlebullet_switch = Util.GetPlayerPrefs(key)

                if chatHandler.IsOpenBulletFunction() or (battlebullet_switch and battlebullet_switch == "true") then
                    this.cur_bullet_chat_open = true
                    showUI(PanelNames.UIBulletChat, 0)
                    this.bullet_mode_controller:SetSelectedIndex(0)
                else
                    this.cur_bullet_chat_open = false
                    this.bullet_mode_controller:SetSelectedIndex(1)
                end
            else
                this.bullet_chat_controller:SetSelectedIndex(1)
                this.bullet_mode_controller:SetSelectedIndex(1)
            end
        else
            if this.bullet_chat_controller then
                this.bullet_chat_controller:SetSelectedIndex(1)
            end
        end
    end

    --战斗开始,随机播放某个英雄的开场语音
    local _partnerModelIds = {}
    for i = 1, #FightManager.fighterList do
        local fighter = FightManager.fighterList[i]
        if fighter.teamIndex == 1 and not fighter.isEmpty then
            table.insert(_partnerModelIds, fighter.partnerModelId)
        end
    end
    if #_partnerModelIds > 0 then
        local _index = Mathf.Random(1, #_partnerModelIds)
        --战斗开始
        AudioManager.PlayInteractionVoice(_partnerModelIds[_index], 0, AudioManager.InteractionTagTable[17].Tag)
    end
    return ;
    --for i=1,#objStarList do
    --    objStarList[i].gameObject:SetActive(false);
    --    for j=1,#imgStarList[i]do
    --        imgStarList[i][j].gameObject:SetActive(false);
    --    end
    --end

    --for i = 1, #imgHeadList do
    --    imgHeadList[i].gameObject:SetActive(false);
    --end

    --if spineAniTimer == nil then
    --    spineAniTimer = Timer.New(this.updateBegin, 1, 1, false);
    --else
    --    spineAniTimer:Reset(this.updateBegin, 1, 1, false);
    --end
    --spineAniTimer:Start();
    --
    --local headIndex = 1;
    --for i = 1, #FightManager.fighterList do
    --    local fighter = FightManager.fighterList[i];
    --    if fighter.teamIndex == 1 and not fighter.isEmpty then
    --        imgHeadList[headIndex]:GetChild("icon").url = "ui://BigHead/tx_" .. fighter.partnerModelId;
    --        imgHeadList[headIndex]:GetChild("icon").visible = true;
    --        --resMgr:LoadIconFromPrefab("", "tx_" , function(sp)
    --        --    log("==========" .. headIndex);
    --        --    imgHeadList[headIndex].sprite = sp;
    --        --end);
    --        local heroData = logicMgr.HeroManager.getHeroDatabyModelId(fighter.partnerModelId);
    --        --local star = heroData.star / 10000;
    --        --imgHeadList[headIndex]:GetController("star").selectedIndex = star;
    --        --if star > 0 then
    --        --    objStarList[i].gameObject:SetActive(true);
    --        --    for j=1,star do
    --        --        imgStarList[i][j].gameObject:SetActive(true);
    --        --    end
    --        --end
    --        headIndex = headIndex + 1;
    --        if headIndex > #imgHeadList then
    --            break
    --        end
    --    end
    --end
end

function UIBattleMain.updateTime(time)
    local t = Mathf.Floor(time);
    if t <= 0 then
        t = 0;
    end
    mainTime.text = timeToTimeFormat_MS(t);
end

function UIBattleMain.uploadReport()
    if (UnityEngine.Application.isMobilePlatform == false) then
        local file2 = io.open("d:/show_test.txt", "w");
        if file2 then
            io.output(file2);
            io.write(FightManager.printMsg);
            io.close(file2);
        end
    end
end

function UIBattleMain.getSkipFuncOpenType()
    if FightManager.fightType == EnumConst.FightTypeConst.DUNGEON then
        return Config.FuncOpenType.MainBattleSkip;
    elseif FightManager.fightType == EnumConst.FightTypeConst.ARENA then
        return Config.FuncOpenType.ArenaBattleSkip;
    elseif FightManager.fightType == EnumConst.FightTypeConst.TOWER then
        return Config.FuncOpenType.TowerBattleSkip
    elseif FightManager.fightType == EnumConst.FightTypeConst.INSTANCE then
        return Config.FuncOpenType.MythicBattleSkip;
    elseif FightManager.fightType == EnumConst.FightTypeConst.Expedition then
        return Config.FuncOpenType.ExpeditionBattleSkip
    elseif FightManager.fightType == EnumConst.FightTypeConst.TRIAL then
        return Config.FuncOpenType.TrialsSkip
    elseif FightManager.fightType == EnumConst.FightTypeConst.GuildBoss then
    elseif FightManager.fightType == EnumConst.FightTypeConst.GuildBattlePlus then
        return Config.FuncOpenType.GuildBattlePlusSkip
    elseif FightManager.fightType == EnumConst.FightTypeConst.StoryBattle then
        return Config.FuncOpenType.StoryModelSkip
    end
    return Config.FuncOpenType.MainBattleSkip
end

---------------------------------------------
---
-------------------------------------------
-- 暂停战斗播放
function UIBattleMain.PauseBattlePlay()
    Time.timeScale = 0
end

-- 继续战斗播放
function UIBattleMain.StartBattlePlay()
    -- Time.timeScale = 1
    if FightManager.curTimeScale then
        Time.timeScale = FightManager.curTimeScale
    else
        Time.timeScale = 1
    end
end

function UIBattleMain.SetChaoTestBoWenEffActive()
    local mapName = logicMgr.MapManager.GetMapNameByFightType(FightManager.fightType);
    if mapName == nil then
        return
    end
    local mapGoName = mapName .. "(Clone)"
    local autoFightMap = panelMgr.BattleRound.transform:Find(mapGoName);
    if autoFightMap then
        local bowenTrans = autoFightMap:Find("BattleMap/Near_0/bowen_01");
        if bowenTrans then
            bowenTrans.gameObject:SetActive(true)
        end
    end
end
--刷新击杀顺序列表
function UIBattleMain.killListRefreshFunc(isTime)
    this.killDataShowList = {}
    local count = 0;
    for i, v in ipairs(this.killDataList) do
        local isRefreshList = false;

        if isTime and not v.isStop then
            v.time = v.time - 100;
        end
        if v.showAni == false then
            isRefreshList = true;
            local item = this.killList:AddItemFromPool()
        end
        if v.time <= -250 and v.time >= -350 and not v.isStop then
            isRefreshList = true;
            this.killList:RemoveChildAt(0);
            v.isStop = true;
        elseif isRefreshList or v.time == 0 then
            this.killListItem(i - 1, this.killList:GetChildAt(count));
        end
        if not v.isStop then
            count = count + 1
        end
    end

    --if isRefreshList then
    --    this.killListRefresh()
    --end
end

function UIBattleMain.killListRefresh()
    --if #this.killDataShowList == 0 then
    --    utimer.remove(this.killListRefreshUTimer);
    --    this.killListRefreshUTimer = nil;
    --end
    --
    --for i, v in ipairs(this.killDataList) do
    --    if this.killList.numItems < #this.killDataShowList then
    --        local item = this.killList.AddItemFromPool()
    --        this.killListItem(i, item);
    --    end
    --
    --end
    --this.killList.numItems = #this.killDataShowList
end

function UIBattleMain.killListItem(idx, obj)
    local data = this.killDataList[idx + 1];
    local teamCtrl = obj:GetController("type");
    local targetHead = obj:GetChild("Btn_Head02");
    local killerHead = obj:GetChild("Btn_Head01");

    if data then
        if not data.showAni then
            data.showAni = true
            local tran = obj:GetTransition("Effect_Show");
            tran:Play()
        end
        if data.time == 0 then
            local tran = obj:GetTransition("Effect_Fade");
            tran:Play()

        end
        local killer = data.killer;
        teamCtrl.selectedIndex = killer.teamIndex == 1 and 0 or 1;
        local fighter = data.fighter;
        local supSkillId = killer.teamIndex == 1 and battleInfo.mySupSkill or battleInfo.enemySupSkill;
        local skillData = G.dataTable["t_skillshow"][tostring(supSkillId)];
        local killerHeadIcon = "ui://ICONAtlas/icon_hero_995";
        if killer.icon == nil and skillData ~= nil then
            --支援技击杀
            killerHeadIcon = "ui://SkillAtlas/" .. skillData.f_SkillIcon;
        elseif killer.icon then
            killerHeadIcon = "ui://ICONAtlas/" .. killer.icon;
        end
        killerHead:GetChild("head"):GetChild("HeadIcon").url = killerHeadIcon;
        local killerHeadCtrl = killerHead:GetController("c3");--外框颜色
        killerHeadCtrl.selectedIndex = killer.teamIndex == 1 and 1 or 2;
        local headIcon = "ui://ICONAtlas/" .. fighter.icon;
        if fighter.icon == nil then
            --支援技击杀
            headIcon = "ui://SkillAtlas/" .. skillData.f_SkillIcon;
        end
        local targetHeadCtrl = targetHead:GetController("c3");--外框颜色
        targetHeadCtrl.selectedIndex = fighter.teamIndex == 1 and 1 or 2;
        targetHead:GetChild("head"):GetChild("HeadIcon").url = headIcon;
    end
end
function UIBattleMain.updateSkillBtn(modelId, check)
    local ctrl = this.skillBtnListByModelId[modelId]:GetController("state")
    if ctrl.selectedIndex ~= 2 then
        ctrl.selectedIndex = check and 1 or 0;
    end
end

function UIBattleMain.checkEnergySkillBtn(modelId)
    local item = this.skillBtnListByModelId[modelId];
    return item:GetChild("energy").value >= 100;
end
----------------------- 风暴峡湾相关 start
--- boss buff列表
---@private
function UIBattleMain.showTrialsBuff()
    this.trialsBuff = logicMgr.TrialsManager.loadTrialsBuff()
    this.trialsBuffPanel = gameObject:GetChild("ChaosBuff")
    this.ctrlTrialsBuff = gameObject:GetController("ChaosBuffInfo")
    this.enemyCombinationSkillList.itemRenderer = function(index, itemobj)
        this.trialsBuffItemRenderer(index + 1, itemobj)
    end

    this.enemyCombinationSkillList.visible = true
    this.enemyCombinationSkillList.numItems = #this.trialsBuff
    this.enemyCombinationSkillListBgCtrl.selectedIndex = #this.trialsBuff > 0 and 1 or 0

    this.loadTrialsBuffPanel()
end
function UIBattleMain.loadTrialsBuffPanel()
    if this.trialsBuffPanel == nil then
        return
    end
    local list = this.trialsBuffPanel:GetChild("list")
    list.itemRenderer = function(index, itemobj)
        this.trialsBuffShowItemRenderer(index + 1, itemobj)
    end
    list.numItems = #this.trialsBuff
end
function UIBattleMain.trialsBuffItemRenderer(index, obj)
    local buffId = this.trialsBuff[index]
    local icon = obj:GetChild("icon")
    local ctrl = obj:GetController("type")
    icon.url = EnumConst.AtlasPath.SkillAtlas .. buffId
    ctrl.selectedIndex = 1

    obj.onClick:Clear()
    obj.onClick:Add(function()
        this.ctrlTrialsBuff.selectedIndex = 1
    end)
end
function UIBattleMain.trialsBuffShowItemRenderer(index, obj)
    local buffId = this.trialsBuff[index]
    local cfg = dataTable.getDataTableByStringId('t_skill', tostring(buffId))
    local icon = obj:GetChild("n4")
    local txtDesc = obj:GetChild("buffDesc")
    icon.url = EnumConst.AtlasPath.SkillAtlas .. buffId
    txtDesc.text = cfg and getLanguage(cfg.f_Desc) or ""
end
----------------------- 风暴峡湾相关 end
-------------------表演战斗
function UIBattleMain.performBattlePlay(is)
    if is then
        this.clickSkip()
    else
        this.onClickPlay()
    end

end
return UIBattleMain;